@cyberkaidev/ui 0.1.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 +20 -0
- package/README.md +721 -0
- package/lib/module/ThemeProvider.js +84 -0
- package/lib/module/ThemeProvider.js.map +1 -0
- package/lib/module/components/AppBar.js +185 -0
- package/lib/module/components/AppBar.js.map +1 -0
- package/lib/module/components/BounceEffect.js +50 -0
- package/lib/module/components/BounceEffect.js.map +1 -0
- package/lib/module/components/Button.js +48 -0
- package/lib/module/components/Button.js.map +1 -0
- package/lib/module/components/Chips.js +94 -0
- package/lib/module/components/Chips.js.map +1 -0
- package/lib/module/components/IconButton.js +71 -0
- package/lib/module/components/IconButton.js.map +1 -0
- package/lib/module/components/InforList.js +92 -0
- package/lib/module/components/InforList.js.map +1 -0
- package/lib/module/components/LoadingApp.js +58 -0
- package/lib/module/components/LoadingApp.js.map +1 -0
- package/lib/module/components/Overlays.js +20 -0
- package/lib/module/components/Overlays.js.map +1 -0
- package/lib/module/components/RippleEffect.js +178 -0
- package/lib/module/components/RippleEffect.js.map +1 -0
- package/lib/module/components/Scaffold.js +172 -0
- package/lib/module/components/Scaffold.js.map +1 -0
- package/lib/module/components/SearchBar.js +161 -0
- package/lib/module/components/SearchBar.js.map +1 -0
- package/lib/module/components/SegmentedButton.js +151 -0
- package/lib/module/components/SegmentedButton.js.map +1 -0
- package/lib/module/components/ShapedButton.js +58 -0
- package/lib/module/components/ShapedButton.js.map +1 -0
- package/lib/module/components/SlideModal.js +196 -0
- package/lib/module/components/SlideModal.js.map +1 -0
- package/lib/module/components/TabBar.js +107 -0
- package/lib/module/components/TabBar.js.map +1 -0
- package/lib/module/components/Text.js +47 -0
- package/lib/module/components/Text.js.map +1 -0
- package/lib/module/components/TextButton.js +53 -0
- package/lib/module/components/TextButton.js.map +1 -0
- package/lib/module/components/TextInput.js +83 -0
- package/lib/module/components/TextInput.js.map +1 -0
- package/lib/module/components/Toast.js +101 -0
- package/lib/module/components/Toast.js.map +1 -0
- package/lib/module/hooks/useAppBarScroll.js +20 -0
- package/lib/module/hooks/useAppBarScroll.js.map +1 -0
- package/lib/module/hooks/usePressAndHoldRepeat.js +71 -0
- package/lib/module/hooks/usePressAndHoldRepeat.js.map +1 -0
- package/lib/module/icons/Icon.js +85 -0
- package/lib/module/icons/Icon.js.map +1 -0
- package/lib/module/index.js +42 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/responsive.js +28 -0
- package/lib/module/responsive.js.map +1 -0
- package/lib/module/stores/useLoadingApp.js +14 -0
- package/lib/module/stores/useLoadingApp.js.map +1 -0
- package/lib/module/stores/useToast.js +24 -0
- package/lib/module/stores/useToast.js.map +1 -0
- package/lib/module/theme.js +86 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/jest.setup.d.ts +2 -0
- package/lib/typescript/jest.setup.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/ThemeProvider.d.ts +39 -0
- package/lib/typescript/src/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/src/components/AppBar.d.ts +33 -0
- package/lib/typescript/src/components/AppBar.d.ts.map +1 -0
- package/lib/typescript/src/components/BounceEffect.d.ts +12 -0
- package/lib/typescript/src/components/BounceEffect.d.ts.map +1 -0
- package/lib/typescript/src/components/Button.d.ts +24 -0
- package/lib/typescript/src/components/Button.d.ts.map +1 -0
- package/lib/typescript/src/components/Chips.d.ts +23 -0
- package/lib/typescript/src/components/Chips.d.ts.map +1 -0
- package/lib/typescript/src/components/IconButton.d.ts +14 -0
- package/lib/typescript/src/components/IconButton.d.ts.map +1 -0
- package/lib/typescript/src/components/InforList.d.ts +28 -0
- package/lib/typescript/src/components/InforList.d.ts.map +1 -0
- package/lib/typescript/src/components/LoadingApp.d.ts +8 -0
- package/lib/typescript/src/components/LoadingApp.d.ts.map +1 -0
- package/lib/typescript/src/components/Overlays.d.ts +12 -0
- package/lib/typescript/src/components/Overlays.d.ts.map +1 -0
- package/lib/typescript/src/components/RippleEffect.d.ts +18 -0
- package/lib/typescript/src/components/RippleEffect.d.ts.map +1 -0
- package/lib/typescript/src/components/Scaffold.d.ts +62 -0
- package/lib/typescript/src/components/Scaffold.d.ts.map +1 -0
- package/lib/typescript/src/components/SearchBar.d.ts +20 -0
- package/lib/typescript/src/components/SearchBar.d.ts.map +1 -0
- package/lib/typescript/src/components/SegmentedButton.d.ts +37 -0
- package/lib/typescript/src/components/SegmentedButton.d.ts.map +1 -0
- package/lib/typescript/src/components/ShapedButton.d.ts +18 -0
- package/lib/typescript/src/components/ShapedButton.d.ts.map +1 -0
- package/lib/typescript/src/components/SlideModal.d.ts +15 -0
- package/lib/typescript/src/components/SlideModal.d.ts.map +1 -0
- package/lib/typescript/src/components/TabBar.d.ts +20 -0
- package/lib/typescript/src/components/TabBar.d.ts.map +1 -0
- package/lib/typescript/src/components/Text.d.ts +26 -0
- package/lib/typescript/src/components/Text.d.ts.map +1 -0
- package/lib/typescript/src/components/TextButton.d.ts +15 -0
- package/lib/typescript/src/components/TextButton.d.ts.map +1 -0
- package/lib/typescript/src/components/TextInput.d.ts +22 -0
- package/lib/typescript/src/components/TextInput.d.ts.map +1 -0
- package/lib/typescript/src/components/Toast.d.ts +4 -0
- package/lib/typescript/src/components/Toast.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useAppBarScroll.d.ts +10 -0
- package/lib/typescript/src/hooks/useAppBarScroll.d.ts.map +1 -0
- package/lib/typescript/src/hooks/usePressAndHoldRepeat.d.ts +21 -0
- package/lib/typescript/src/hooks/usePressAndHoldRepeat.d.ts.map +1 -0
- package/lib/typescript/src/icons/Icon.d.ts +64 -0
- package/lib/typescript/src/icons/Icon.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +30 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/responsive.d.ts +15 -0
- package/lib/typescript/src/responsive.d.ts.map +1 -0
- package/lib/typescript/src/stores/useLoadingApp.d.ts +14 -0
- package/lib/typescript/src/stores/useLoadingApp.d.ts.map +1 -0
- package/lib/typescript/src/stores/useToast.d.ts +25 -0
- package/lib/typescript/src/stores/useToast.d.ts.map +1 -0
- package/lib/typescript/src/theme.d.ts +51 -0
- package/lib/typescript/src/theme.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +26 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +189 -0
- package/src/ThemeProvider.tsx +108 -0
- package/src/components/AppBar.tsx +226 -0
- package/src/components/BounceEffect.tsx +53 -0
- package/src/components/Button.tsx +70 -0
- package/src/components/Chips.tsx +115 -0
- package/src/components/IconButton.tsx +84 -0
- package/src/components/InforList.tsx +110 -0
- package/src/components/LoadingApp.tsx +55 -0
- package/src/components/Overlays.tsx +21 -0
- package/src/components/RippleEffect.tsx +244 -0
- package/src/components/Scaffold.tsx +219 -0
- package/src/components/SearchBar.tsx +166 -0
- package/src/components/SegmentedButton.tsx +206 -0
- package/src/components/ShapedButton.tsx +74 -0
- package/src/components/SlideModal.tsx +232 -0
- package/src/components/TabBar.tsx +122 -0
- package/src/components/Text.tsx +70 -0
- package/src/components/TextButton.tsx +57 -0
- package/src/components/TextInput.tsx +108 -0
- package/src/components/Toast.tsx +95 -0
- package/src/hooks/useAppBarScroll.ts +19 -0
- package/src/hooks/usePressAndHoldRepeat.ts +85 -0
- package/src/icons/Icon.tsx +51 -0
- package/src/index.tsx +64 -0
- package/src/responsive.ts +32 -0
- package/src/stores/useLoadingApp.ts +19 -0
- package/src/stores/useToast.ts +36 -0
- package/src/theme.ts +125 -0
- package/src/types.ts +27 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
declare const names: {
|
|
2
|
+
check: {
|
|
3
|
+
ios: "checkmark";
|
|
4
|
+
android: "check";
|
|
5
|
+
};
|
|
6
|
+
remove: {
|
|
7
|
+
ios: "minus";
|
|
8
|
+
android: "remove";
|
|
9
|
+
};
|
|
10
|
+
add: {
|
|
11
|
+
ios: "plus";
|
|
12
|
+
android: "add";
|
|
13
|
+
};
|
|
14
|
+
settings: {
|
|
15
|
+
ios: "gear";
|
|
16
|
+
android: "settings";
|
|
17
|
+
};
|
|
18
|
+
arrow_back: {
|
|
19
|
+
ios: "chevron.left";
|
|
20
|
+
android: "arrow_back";
|
|
21
|
+
};
|
|
22
|
+
search: {
|
|
23
|
+
ios: "magnifyingglass";
|
|
24
|
+
android: "search";
|
|
25
|
+
};
|
|
26
|
+
edit: {
|
|
27
|
+
ios: "pencil";
|
|
28
|
+
android: "edit";
|
|
29
|
+
};
|
|
30
|
+
error: {
|
|
31
|
+
ios: "x.circle";
|
|
32
|
+
android: "error";
|
|
33
|
+
};
|
|
34
|
+
close: {
|
|
35
|
+
ios: "xmark";
|
|
36
|
+
android: "close";
|
|
37
|
+
};
|
|
38
|
+
folder: {
|
|
39
|
+
ios: "folder";
|
|
40
|
+
android: "folder";
|
|
41
|
+
};
|
|
42
|
+
question: {
|
|
43
|
+
ios: "questionmark";
|
|
44
|
+
android: "question_mark";
|
|
45
|
+
};
|
|
46
|
+
filter: {
|
|
47
|
+
ios: "line.3.horizontal.decrease";
|
|
48
|
+
android: "filter_list";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export type IconNameType = keyof typeof names;
|
|
52
|
+
type Props = {
|
|
53
|
+
/** One of the curated icon names. */
|
|
54
|
+
name: IconNameType;
|
|
55
|
+
/** Icon color. Defaults to the theme `primary`. */
|
|
56
|
+
color?: string;
|
|
57
|
+
/** Size in dp. Defaults to the theme `iconSize.m`. */
|
|
58
|
+
size?: number;
|
|
59
|
+
testID?: string;
|
|
60
|
+
};
|
|
61
|
+
/** Renders a curated UI icon via `expo-symbols` (`SymbolView`). */
|
|
62
|
+
export declare function Icon({ name, color, size, testID }: Props): import("react").JSX.Element;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=Icon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../../src/icons/Icon.tsx"],"names":[],"mappings":"AAOA,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAa0D,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,KAAK,CAAC;AAE9C,KAAK,KAAK,GAAG;IACX,qCAAqC;IACrC,IAAI,EAAE,YAAY,CAAC;IACnB,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,mEAAmE;AACnE,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,+BAexD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export * from './components/AppBar.js';
|
|
2
|
+
export * from './components/BounceEffect.js';
|
|
3
|
+
export * from './components/Button.js';
|
|
4
|
+
export * from './components/Chips.js';
|
|
5
|
+
export * from './components/IconButton.js';
|
|
6
|
+
export * from './components/InforList.js';
|
|
7
|
+
export * from './components/LoadingApp.js';
|
|
8
|
+
export * from './components/Overlays.js';
|
|
9
|
+
export * from './components/RippleEffect.js';
|
|
10
|
+
export * from './components/Scaffold.js';
|
|
11
|
+
export * from './components/SearchBar.js';
|
|
12
|
+
export * from './components/SegmentedButton.js';
|
|
13
|
+
export * from './components/ShapedButton.js';
|
|
14
|
+
export * from './components/SlideModal.js';
|
|
15
|
+
export * from './components/TabBar.js';
|
|
16
|
+
export * from './components/Text.js';
|
|
17
|
+
export * from './components/TextButton.js';
|
|
18
|
+
export * from './components/TextInput.js';
|
|
19
|
+
export * from './components/Toast.js';
|
|
20
|
+
export * from './icons/Icon.js';
|
|
21
|
+
export { ThemeProvider, useTheme, useColors, useThemedStyles, } from './ThemeProvider.js';
|
|
22
|
+
export { colors, fontSizes, iconSize, spaces, borderRadius, pageSpacing, defaultTokens, } from './theme.js';
|
|
23
|
+
export type { ThemeType, ThemeTokensType, FontSizesType, IconSizesType, SpacesType, SpaceScaleType, BorderRadiusType, PageSpacingType, } from './theme.js';
|
|
24
|
+
export { widthDP, heightDP } from './responsive.js';
|
|
25
|
+
export * from './hooks/useAppBarScroll.js';
|
|
26
|
+
export * from './hooks/usePressAndHoldRepeat.js';
|
|
27
|
+
export { useToast } from './stores/useToast.js';
|
|
28
|
+
export { useLoadingApp } from './stores/useLoadingApp.js';
|
|
29
|
+
export type * from './types.js';
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,cAAc,wBAAqB,CAAC;AACpC,cAAc,8BAA2B,CAAC;AAC1C,cAAc,wBAAqB,CAAC;AACpC,cAAc,uBAAoB,CAAC;AACnC,cAAc,4BAAyB,CAAC;AACxC,cAAc,2BAAwB,CAAC;AACvC,cAAc,4BAAyB,CAAC;AACxC,cAAc,0BAAuB,CAAC;AACtC,cAAc,8BAA2B,CAAC;AAC1C,cAAc,0BAAuB,CAAC;AACtC,cAAc,2BAAwB,CAAC;AACvC,cAAc,iCAA8B,CAAC;AAC7C,cAAc,8BAA2B,CAAC;AAC1C,cAAc,4BAAyB,CAAC;AACxC,cAAc,wBAAqB,CAAC;AACpC,cAAc,sBAAmB,CAAC;AAClC,cAAc,4BAAyB,CAAC;AACxC,cAAc,2BAAwB,CAAC;AACvC,cAAc,uBAAoB,CAAC;AAGnC,cAAc,iBAAc,CAAC;AAG7B,OAAO,EACL,aAAa,EACb,QAAQ,EACR,SAAS,EACT,eAAe,GAChB,MAAM,oBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,SAAS,EACT,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,WAAW,EACX,aAAa,GACd,MAAM,YAAS,CAAC;AACjB,YAAY,EACV,SAAS,EACT,eAAe,EACf,aAAa,EACb,aAAa,EACb,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAS,CAAC;AAGjB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAc,CAAC;AAGjD,cAAc,4BAAyB,CAAC;AACxC,cAAc,kCAA+B,CAAC;AAG9C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAAwB,CAAC;AAGvD,mBAAmB,YAAS,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a percentage of the screen width to a density-independent pixel value.
|
|
3
|
+
*
|
|
4
|
+
* @param widthPercent Percentage of the screen width (number, or numeric string).
|
|
5
|
+
* @returns The value in dp, rounded to the nearest physical pixel.
|
|
6
|
+
*/
|
|
7
|
+
export declare function widthDP(widthPercent: string | number): number;
|
|
8
|
+
/**
|
|
9
|
+
* Convert a percentage of the screen height to a density-independent pixel value.
|
|
10
|
+
*
|
|
11
|
+
* @param heightPercent Percentage of the screen height (number, or numeric string).
|
|
12
|
+
* @returns The value in dp, rounded to the nearest physical pixel.
|
|
13
|
+
*/
|
|
14
|
+
export declare function heightDP(heightPercent: string | number): number;
|
|
15
|
+
//# sourceMappingURL=responsive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsive.d.ts","sourceRoot":"","sources":["../../../src/responsive.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAK7D;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAO/D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type State = {
|
|
2
|
+
visible: boolean;
|
|
3
|
+
};
|
|
4
|
+
type Actions = {
|
|
5
|
+
/** Toggle the blocking loading overlay. */
|
|
6
|
+
setLoadingVisible: (visible: boolean) => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Global state for the blocking `<LoadingApp />` overlay. Render it once near
|
|
10
|
+
* the root and drive it with `useLoadingApp.getState().setLoadingVisible(...)`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useLoadingApp: import("zustand").UseBoundStore<import("zustand").StoreApi<State & Actions>>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=useLoadingApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLoadingApp.d.ts","sourceRoot":"","sources":["../../../../src/stores/useLoadingApp.ts"],"names":[],"mappings":"AAEA,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,2CAA2C;IAC3C,iBAAiB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,8EAGvB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ToastVariantType } from '../types.js';
|
|
2
|
+
type ShowToastArgs = {
|
|
3
|
+
/** Text shown in the toast. */
|
|
4
|
+
message: string;
|
|
5
|
+
/** Visual intent. Defaults to `'info'`. */
|
|
6
|
+
variant?: ToastVariantType;
|
|
7
|
+
};
|
|
8
|
+
type State = {
|
|
9
|
+
visible: boolean;
|
|
10
|
+
variant: ToastVariantType;
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
type Actions = {
|
|
14
|
+
/** Show the toast with a message and optional variant. */
|
|
15
|
+
showToast: (args: ShowToastArgs) => void;
|
|
16
|
+
/** Hide the toast. */
|
|
17
|
+
hideToast: () => void;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Global toast state. Render `<Toast />` once near the root; call
|
|
21
|
+
* `useToast.getState().showToast(...)` (or the hook) from anywhere.
|
|
22
|
+
*/
|
|
23
|
+
export declare const useToast: import("zustand").UseBoundStore<import("zustand").StoreApi<State & Actions>>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=useToast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useToast.d.ts","sourceRoot":"","sources":["../../../../src/stores/useToast.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAU,CAAC;AAEjD,KAAK,aAAa,GAAG;IACnB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,0DAA0D;IAC1D,SAAS,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,sBAAsB;IACtB,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,8EAOlB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ColorsType, FontSizeType, IconSizeType } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A ready-made color palette. `ThemeProvider` **requires** a `colors` prop — pass
|
|
4
|
+
* this, spread from it, or provide your own `ColorsType`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const colors: ColorsType;
|
|
7
|
+
export type FontSizesType = Record<FontSizeType, number>;
|
|
8
|
+
/** Default font sizes, in dp. */
|
|
9
|
+
export declare const fontSizes: FontSizesType;
|
|
10
|
+
export type IconSizesType = Record<IconSizeType, number>;
|
|
11
|
+
/** Default icon sizes, in dp. */
|
|
12
|
+
export declare const iconSize: IconSizesType;
|
|
13
|
+
export type SpaceScaleType = 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';
|
|
14
|
+
export type SpacesType = {
|
|
15
|
+
horizontal: Record<SpaceScaleType, number>;
|
|
16
|
+
vertical: Record<SpaceScaleType, number>;
|
|
17
|
+
};
|
|
18
|
+
/** Default spacing scale, in dp. */
|
|
19
|
+
export declare const spaces: SpacesType;
|
|
20
|
+
export type BorderRadiusType = {
|
|
21
|
+
radius_5: number;
|
|
22
|
+
radius_10: number;
|
|
23
|
+
radius_15: number;
|
|
24
|
+
radius_20: number;
|
|
25
|
+
radius_100: number | string;
|
|
26
|
+
};
|
|
27
|
+
/** Default border radius scale. */
|
|
28
|
+
export declare const borderRadius: BorderRadiusType;
|
|
29
|
+
export type PageSpacingType = {
|
|
30
|
+
horizontal: number;
|
|
31
|
+
top: number;
|
|
32
|
+
bottom: number;
|
|
33
|
+
};
|
|
34
|
+
/** Default page insets used by `Scaffold` and the fixed bars. */
|
|
35
|
+
export declare const pageSpacing: PageSpacingType;
|
|
36
|
+
export type ThemeType = {
|
|
37
|
+
colors: ColorsType;
|
|
38
|
+
fontSizes: FontSizesType;
|
|
39
|
+
iconSize: IconSizesType;
|
|
40
|
+
spaces: SpacesType;
|
|
41
|
+
borderRadius: BorderRadiusType;
|
|
42
|
+
pageSpacing: PageSpacingType;
|
|
43
|
+
};
|
|
44
|
+
/** Everything in `ThemeType` except `colors`. */
|
|
45
|
+
export type ThemeTokensType = Omit<ThemeType, 'colors'>;
|
|
46
|
+
/**
|
|
47
|
+
* Defaults for the non-color token groups. `ThemeProvider` merges any override
|
|
48
|
+
* on top of these (there is no default palette — `colors` is required).
|
|
49
|
+
*/
|
|
50
|
+
export declare const defaultTokens: ThemeTokensType;
|
|
51
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAS,CAAC;AAEtE;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,UAapB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAEzD,iCAAiC;AACjC,eAAO,MAAM,SAAS,EAAE,aAQvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAEzD,iCAAiC;AACjC,eAAO,MAAM,QAAQ,EAAE,aAKtB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,KAAK,CAAC;AAEnE,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAEF,oCAAoC;AACpC,eAAO,MAAM,MAAM,EAAE,UAiBpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B,CAAC;AAEF,mCAAmC;AACnC,eAAO,MAAM,YAAY,EAAE,gBAM1B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,WAAW,EAAE,eAIzB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,aAAa,CAAC;IACzB,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,WAAW,EAAE,eAAe,CAAC;CAC9B,CAAC;AAEF,iDAAiD;AACjD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,eAM3B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type FontSizeType = 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';
|
|
2
|
+
export type IconSizeType = 's' | 'm' | 'l' | 'xl';
|
|
3
|
+
export type TextAlignType = 'left' | 'center' | 'right';
|
|
4
|
+
export type FontWeightType = 'regular' | 'medium' | 'bold';
|
|
5
|
+
/**
|
|
6
|
+
* Shape of the color palette consumed by every component in the library.
|
|
7
|
+
* All values are plain color strings so they can be dropped straight into
|
|
8
|
+
* React Native styles.
|
|
9
|
+
*/
|
|
10
|
+
export type ColorsType = {
|
|
11
|
+
background: string;
|
|
12
|
+
background_60: string;
|
|
13
|
+
on_surface: string;
|
|
14
|
+
surface: string;
|
|
15
|
+
surface_90: string;
|
|
16
|
+
border: string;
|
|
17
|
+
text: string;
|
|
18
|
+
primary: string;
|
|
19
|
+
red: string;
|
|
20
|
+
green: string;
|
|
21
|
+
amber: string;
|
|
22
|
+
transparent: string;
|
|
23
|
+
};
|
|
24
|
+
/** Visual intent of a `Toast`. Replaces the domain-specific `ToastType` enum. */
|
|
25
|
+
export type ToastVariantType = 'error' | 'success' | 'info';
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;AAC1E,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;AAClD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AACxD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE3D;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,iFAAiF;AACjF,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cyberkaidev/ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Components for React Native",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"cyberkaidev-ui-source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"!**/__tests__",
|
|
19
|
+
"!**/__fixtures__",
|
|
20
|
+
"!**/__mocks__",
|
|
21
|
+
"!**/.*"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"example": "yarn workspace @cyberkaidev/ui-example",
|
|
25
|
+
"clean": "del-cli lib",
|
|
26
|
+
"prepare": "bob build",
|
|
27
|
+
"typecheck": "tsc",
|
|
28
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
29
|
+
"test": "jest",
|
|
30
|
+
"release": "release-it --only-version"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"react-native",
|
|
34
|
+
"ios",
|
|
35
|
+
"android"
|
|
36
|
+
],
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/cyberkaidev/ui.git"
|
|
40
|
+
},
|
|
41
|
+
"author": "Kaique Dourado <cyberkaidev@gmail.com> (https://github.com/cyberkaidev)",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/cyberkaidev/ui/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/cyberkaidev/ui#readme",
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"registry": "https://registry.npmjs.org/",
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@commitlint/config-conventional": "^21.0.2",
|
|
53
|
+
"@eslint/compat": "^2.1.0",
|
|
54
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
55
|
+
"@eslint/js": "^10.0.1",
|
|
56
|
+
"@react-native/babel-preset": "0.85.0",
|
|
57
|
+
"@react-native/eslint-config": "0.85.0",
|
|
58
|
+
"@react-native/jest-preset": "0.85.0",
|
|
59
|
+
"@release-it/conventional-changelog": "^11.0.1",
|
|
60
|
+
"@shopify/flash-list": "2.0.2",
|
|
61
|
+
"@testing-library/react-native": "^13.2.0",
|
|
62
|
+
"@types/jest": "^29.5.14",
|
|
63
|
+
"@types/react": "^19.2.0",
|
|
64
|
+
"commitlint": "^21.0.2",
|
|
65
|
+
"del-cli": "^7.0.0",
|
|
66
|
+
"eslint": "^9.39.4",
|
|
67
|
+
"eslint-config-prettier": "^10.1.8",
|
|
68
|
+
"eslint-plugin-ft-flow": "^3.0.11",
|
|
69
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
70
|
+
"expo": "~55.0.30",
|
|
71
|
+
"expo-blur": "~55.0.18",
|
|
72
|
+
"expo-constants": "~55.0.17",
|
|
73
|
+
"expo-symbols": "~55.0.9",
|
|
74
|
+
"jest": "^29.7.0",
|
|
75
|
+
"lefthook": "^2.1.9",
|
|
76
|
+
"prettier": "^3.8.3",
|
|
77
|
+
"react": "19.2.0",
|
|
78
|
+
"react-native": "0.83.10",
|
|
79
|
+
"react-native-builder-bob": "^0.43.0",
|
|
80
|
+
"react-native-reanimated": "4.2.1",
|
|
81
|
+
"react-native-safe-area-context": "~5.6.2",
|
|
82
|
+
"react-native-worklets": "0.7.4",
|
|
83
|
+
"react-test-renderer": "19.2.0",
|
|
84
|
+
"release-it": "^20.2.0",
|
|
85
|
+
"typescript": "^6.0.3"
|
|
86
|
+
},
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"zustand": "^5.0.8"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"@shopify/flash-list": ">=2.0.0",
|
|
92
|
+
"expo": "*",
|
|
93
|
+
"expo-blur": "*",
|
|
94
|
+
"expo-constants": "*",
|
|
95
|
+
"expo-symbols": "*",
|
|
96
|
+
"react": "*",
|
|
97
|
+
"react-native": "*",
|
|
98
|
+
"react-native-reanimated": ">=4.0.0",
|
|
99
|
+
"react-native-safe-area-context": "*",
|
|
100
|
+
"react-native-worklets": "*"
|
|
101
|
+
},
|
|
102
|
+
"workspaces": [
|
|
103
|
+
"example"
|
|
104
|
+
],
|
|
105
|
+
"packageManager": "yarn@4.11.0",
|
|
106
|
+
"react-native-builder-bob": {
|
|
107
|
+
"source": "src",
|
|
108
|
+
"output": "lib",
|
|
109
|
+
"targets": [
|
|
110
|
+
[
|
|
111
|
+
"module",
|
|
112
|
+
{
|
|
113
|
+
"esm": true
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
[
|
|
117
|
+
"typescript",
|
|
118
|
+
{
|
|
119
|
+
"project": "tsconfig.build.json"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
"prettier": {
|
|
125
|
+
"quoteProps": "consistent",
|
|
126
|
+
"singleQuote": true,
|
|
127
|
+
"tabWidth": 2,
|
|
128
|
+
"trailingComma": "es5",
|
|
129
|
+
"useTabs": false
|
|
130
|
+
},
|
|
131
|
+
"jest": {
|
|
132
|
+
"preset": "@react-native/jest-preset",
|
|
133
|
+
"setupFilesAfterEnv": [
|
|
134
|
+
"<rootDir>/jest.setup.ts"
|
|
135
|
+
],
|
|
136
|
+
"testEnvironmentOptions": {
|
|
137
|
+
"customExportConditions": [
|
|
138
|
+
"require",
|
|
139
|
+
"react-native",
|
|
140
|
+
"cyberkaidev-ui-source"
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
"transformIgnorePatterns": [
|
|
144
|
+
"node_modules/(?!(?:jest-)?react-native|@react-native(-community)?|react-native-reanimated|react-native-worklets|react-native-safe-area-context|@shopify/flash-list|@expo|expo(-.*)?|expo-modules-core)"
|
|
145
|
+
],
|
|
146
|
+
"testMatch": [
|
|
147
|
+
"<rootDir>/src/**/__tests__/**/*.(test|spec).(ts|tsx)"
|
|
148
|
+
],
|
|
149
|
+
"modulePathIgnorePatterns": [
|
|
150
|
+
"<rootDir>/example/node_modules",
|
|
151
|
+
"<rootDir>/lib/"
|
|
152
|
+
]
|
|
153
|
+
},
|
|
154
|
+
"commitlint": {
|
|
155
|
+
"extends": [
|
|
156
|
+
"@commitlint/config-conventional"
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
"release-it": {
|
|
160
|
+
"git": {
|
|
161
|
+
"commitMessage": "chore: release ${version}",
|
|
162
|
+
"tagName": "v${version}"
|
|
163
|
+
},
|
|
164
|
+
"npm": {
|
|
165
|
+
"publish": true
|
|
166
|
+
},
|
|
167
|
+
"github": {
|
|
168
|
+
"release": true
|
|
169
|
+
},
|
|
170
|
+
"plugins": {
|
|
171
|
+
"@release-it/conventional-changelog": {
|
|
172
|
+
"preset": {
|
|
173
|
+
"name": "angular"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
"create-react-native-library": {
|
|
179
|
+
"type": "library",
|
|
180
|
+
"languages": "js",
|
|
181
|
+
"tools": [
|
|
182
|
+
"eslint",
|
|
183
|
+
"jest",
|
|
184
|
+
"lefthook",
|
|
185
|
+
"release-it"
|
|
186
|
+
],
|
|
187
|
+
"version": "0.63.0"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { defaultTokens } from './theme';
|
|
4
|
+
import type {
|
|
5
|
+
BorderRadiusType,
|
|
6
|
+
FontSizesType,
|
|
7
|
+
IconSizesType,
|
|
8
|
+
PageSpacingType,
|
|
9
|
+
SpacesType,
|
|
10
|
+
ThemeType,
|
|
11
|
+
} from './theme';
|
|
12
|
+
import type { ColorsType } from './types';
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
/**
|
|
16
|
+
* The full color palette. **Required** — there is no default. Pass the
|
|
17
|
+
* exported `colors` palette, spread from it, or provide your own.
|
|
18
|
+
*/
|
|
19
|
+
colors: ColorsType;
|
|
20
|
+
/** Partial overrides for the non-color token groups; missing keys fall back
|
|
21
|
+
* to the parent `ThemeProvider`, or to the built-in defaults. */
|
|
22
|
+
fontSizes?: Partial<FontSizesType>;
|
|
23
|
+
iconSize?: Partial<IconSizesType>;
|
|
24
|
+
spaces?: {
|
|
25
|
+
horizontal?: Partial<SpacesType['horizontal']>;
|
|
26
|
+
vertical?: Partial<SpacesType['vertical']>;
|
|
27
|
+
};
|
|
28
|
+
borderRadius?: Partial<BorderRadiusType>;
|
|
29
|
+
pageSpacing?: Partial<PageSpacingType>;
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const ThemeContext = React.createContext<ThemeType | null>(null);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Injects the theme into the tree. `colors` is required; the other token groups
|
|
37
|
+
* are optional and merge over the nearest parent `ThemeProvider` (or the
|
|
38
|
+
* defaults). Providers nest.
|
|
39
|
+
*/
|
|
40
|
+
export function ThemeProvider({
|
|
41
|
+
colors,
|
|
42
|
+
fontSizes,
|
|
43
|
+
iconSize,
|
|
44
|
+
spaces,
|
|
45
|
+
borderRadius,
|
|
46
|
+
pageSpacing,
|
|
47
|
+
children,
|
|
48
|
+
}: Props) {
|
|
49
|
+
const parent = React.useContext(ThemeContext);
|
|
50
|
+
|
|
51
|
+
const value = React.useMemo<ThemeType>(() => {
|
|
52
|
+
const baseSpaces = parent?.spaces ?? defaultTokens.spaces;
|
|
53
|
+
return {
|
|
54
|
+
colors,
|
|
55
|
+
fontSizes: {
|
|
56
|
+
...(parent?.fontSizes ?? defaultTokens.fontSizes),
|
|
57
|
+
...fontSizes,
|
|
58
|
+
},
|
|
59
|
+
iconSize: {
|
|
60
|
+
...(parent?.iconSize ?? defaultTokens.iconSize),
|
|
61
|
+
...iconSize,
|
|
62
|
+
},
|
|
63
|
+
spaces: {
|
|
64
|
+
horizontal: { ...baseSpaces.horizontal, ...spaces?.horizontal },
|
|
65
|
+
vertical: { ...baseSpaces.vertical, ...spaces?.vertical },
|
|
66
|
+
},
|
|
67
|
+
borderRadius: {
|
|
68
|
+
...(parent?.borderRadius ?? defaultTokens.borderRadius),
|
|
69
|
+
...borderRadius,
|
|
70
|
+
},
|
|
71
|
+
pageSpacing: {
|
|
72
|
+
...(parent?.pageSpacing ?? defaultTokens.pageSpacing),
|
|
73
|
+
...pageSpacing,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}, [parent, colors, fontSizes, iconSize, spaces, borderRadius, pageSpacing]);
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The resolved theme. Throws if used outside a `ThemeProvider`. */
|
|
84
|
+
export function useTheme(): ThemeType {
|
|
85
|
+
const theme = React.useContext(ThemeContext);
|
|
86
|
+
if (!theme) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
'@cyberkaidev/ui: a component was rendered outside <ThemeProvider>. ' +
|
|
89
|
+
'Wrap your app in <ThemeProvider colors={...}>.'
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return theme;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Convenience: the resolved color palette (`useTheme().colors`). */
|
|
96
|
+
export function useColors(): ColorsType {
|
|
97
|
+
return useTheme().colors;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Builds a value (usually a `StyleSheet`) from the resolved theme, memoized
|
|
102
|
+
* against it. Pass a module-level factory so it stays referentially stable and
|
|
103
|
+
* the memo only recomputes when the theme actually changes.
|
|
104
|
+
*/
|
|
105
|
+
export function useThemedStyles<T>(factory: (theme: ThemeType) => T): T {
|
|
106
|
+
const theme = useTheme();
|
|
107
|
+
return React.useMemo(() => factory(theme), [theme, factory]);
|
|
108
|
+
}
|