@apple-pie/slice-native 0.1.3 → 0.1.6
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/README.md +196 -6
- package/dist/cjs/components.js +15 -0
- package/dist/cjs/hooks.js +7 -0
- package/dist/cjs/index.js +18 -805
- package/dist/cjs/providers.js +9 -0
- package/dist/cjs/src/components/SliceButton/SliceButton.js +119 -0
- package/dist/cjs/src/components/SliceIcon/SliceIcon.js +20 -0
- package/dist/cjs/src/components/SliceIcon/iconRegistry.js +668 -0
- package/dist/cjs/src/components/SliceIcon/icons.js +144 -0
- package/dist/cjs/src/components/SliceText/SliceText.js +21 -0
- package/dist/cjs/src/components/SliceTextInput/SliceTextInput.js +87 -0
- package/dist/cjs/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +13 -0
- package/dist/cjs/src/providers/SliceThemeProvider.js +37 -0
- package/dist/cjs/src/theme/colors/colors.js +253 -0
- package/dist/cjs/src/theme/corners/corners.js +14 -0
- package/dist/cjs/src/theme/elevations/elevations.js +17 -0
- package/dist/cjs/src/theme/motion/motion.js +15 -0
- package/dist/cjs/src/theme/motion.js +47 -0
- package/dist/cjs/src/theme/spacing/spacing.js +14 -0
- package/dist/cjs/src/theme/type/type.js +190 -0
- package/dist/cjs/src/utils/typography/typography.js +17 -0
- package/dist/cjs/theme.js +23 -538
- package/dist/cjs/utils.js +7 -0
- package/dist/esm/components.mjs +5 -0
- package/dist/esm/hooks.mjs +1 -0
- package/dist/esm/index.mjs +8 -806
- package/dist/esm/providers.mjs +1 -0
- package/dist/esm/src/components/SliceButton/SliceButton.mjs +117 -0
- package/dist/esm/src/components/SliceIcon/SliceIcon.mjs +18 -0
- package/dist/esm/src/components/SliceIcon/iconRegistry.mjs +666 -0
- package/dist/esm/src/components/SliceIcon/icons.mjs +142 -0
- package/dist/esm/src/components/SliceText/SliceText.mjs +19 -0
- package/dist/esm/src/components/SliceTextInput/SliceTextInput.mjs +85 -0
- package/dist/esm/src/hooks/useCreateThemedStyles/useCreateThemedStyles.mjs +11 -0
- package/dist/esm/src/providers/SliceThemeProvider.mjs +33 -0
- package/dist/esm/src/theme/colors/colors.mjs +249 -0
- package/dist/esm/src/theme/corners/corners.mjs +12 -0
- package/dist/esm/src/theme/elevations/elevations.mjs +15 -0
- package/dist/esm/src/theme/motion/motion.mjs +13 -0
- package/dist/esm/src/theme/motion.mjs +45 -0
- package/dist/esm/src/theme/spacing/spacing.mjs +12 -0
- package/dist/esm/src/theme/type/type.mjs +184 -0
- package/dist/esm/src/utils/typography/typography.mjs +15 -0
- package/dist/esm/theme.mjs +7 -522
- package/dist/esm/utils.mjs +1 -0
- package/dist/types/native/index.d.ts +8 -4
- package/dist/types/native/src/components/SliceButton/SliceButton.d.ts +5 -0
- package/dist/types/native/src/components/SliceButton/_types.d.ts +47 -0
- package/dist/types/native/src/components/SliceButton/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceIcon/SliceIcon.d.ts +2 -0
- package/dist/types/native/{components/Icon → src/components/SliceIcon}/icons.d.ts +2 -0
- package/dist/types/native/src/components/SliceIcon/index.d.ts +3 -0
- package/dist/types/native/src/components/SliceText/SliceText.d.ts +5 -0
- package/dist/types/native/src/components/SliceText/_types.d.ts +17 -0
- package/dist/types/native/src/components/SliceText/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceTextInput/SliceTextInput.d.ts +2 -0
- package/dist/types/native/src/components/SliceTextInput/_types.d.ts +36 -0
- package/dist/types/native/src/components/SliceTextInput/index.d.ts +2 -0
- package/dist/types/native/src/components/index.d.ts +8 -0
- package/dist/types/native/src/hooks/index.d.ts +1 -0
- package/dist/types/native/src/hooks/useCreateThemedStyles/index.d.ts +1 -0
- package/dist/types/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.d.ts +7 -0
- package/dist/types/native/src/providers/SliceThemeProvider.d.ts +16 -0
- package/dist/types/native/src/providers/index.d.ts +2 -0
- package/dist/types/native/{theme → src/theme}/index.d.ts +5 -5
- package/dist/types/native/src/utils/index.d.ts +1 -0
- package/dist/types/native/src/utils/typography/index.d.ts +1 -0
- package/dist/types/native/src/utils/typography/typography.d.ts +7 -0
- package/package.json +32 -3
- package/dist/types/native/components/Icon/NativeIcon.d.ts +0 -2
- package/dist/types/native/components/Icon/index.d.ts +0 -3
- /package/dist/types/native/{components/Icon → src/components/SliceIcon}/_types.d.ts +0 -0
- /package/dist/types/native/{components/Icon → src/components/SliceIcon}/iconRegistry.d.ts +0 -0
- /package/dist/types/native/{theme → src/theme}/motion.d.ts +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { TextInputProps } from 'react-native';
|
|
2
|
+
import type { BaseAnimationBuilder, LayoutAnimationFunction } from 'react-native-reanimated';
|
|
3
|
+
export interface SliceTextInputProps extends TextInputProps {
|
|
4
|
+
/**
|
|
5
|
+
* emits directive focus event
|
|
6
|
+
*/
|
|
7
|
+
didFocus?: (focused: boolean) => void;
|
|
8
|
+
/**
|
|
9
|
+
* enables applying animations when the input layout changes using reanimated layout functions
|
|
10
|
+
*/
|
|
11
|
+
layout?: typeof BaseAnimationBuilder | BaseAnimationBuilder | LayoutAnimationFunction;
|
|
12
|
+
/**
|
|
13
|
+
* When true, blur clears the input and calls onChangeText with an empty string. Default: false.
|
|
14
|
+
*/
|
|
15
|
+
blurClears?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Adds a slice icon to the start of the input field
|
|
18
|
+
*/
|
|
19
|
+
icon?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optionally define the icon color
|
|
22
|
+
*/
|
|
23
|
+
iconColor?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optionally define the icon size
|
|
26
|
+
*/
|
|
27
|
+
iconSize?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Optionally hide icon when input is focused - default = true
|
|
30
|
+
*/
|
|
31
|
+
hideIconOnFocus?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Expose a way to set focus on input from external events
|
|
34
|
+
*/
|
|
35
|
+
focused?: boolean;
|
|
36
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SliceIcon, SliceIcons } from './SliceIcon';
|
|
2
|
+
export type { IconProps, SliceIconProps } from './SliceIcon';
|
|
3
|
+
export { StyledText } from './SliceText';
|
|
4
|
+
export type { StyledTextProps } from './SliceText';
|
|
5
|
+
export { SliceButton } from './SliceButton';
|
|
6
|
+
export type { SliceButtonProps } from './SliceButton';
|
|
7
|
+
export { SliceTextInput } from './SliceTextInput';
|
|
8
|
+
export type { SliceTextInputProps } from './SliceTextInput';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useCreateThemedStyles } from './useCreateThemedStyles';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useCreateThemedStyles } from './useCreateThemedStyles';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
import type { SliceNativeTheme } from '../../theme';
|
|
3
|
+
/** Resolve native styles using the current provider theme. Keep the factory stable
|
|
4
|
+
* (outside the component, or with useCallback) to reuse styles across renders. */
|
|
5
|
+
export declare function useCreateThemedStyles<T extends {
|
|
6
|
+
[K in keyof T]: ViewStyle | TextStyle | ImageStyle;
|
|
7
|
+
}>(styles: (theme: SliceNativeTheme) => T): T;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type SliceNativeTheme } from '../theme';
|
|
3
|
+
export type ThemePreference = 'system' | 'light' | 'dark';
|
|
4
|
+
export type ThemeContextValue = {
|
|
5
|
+
theme: SliceNativeTheme;
|
|
6
|
+
mode: 'light' | 'dark';
|
|
7
|
+
preference: ThemePreference;
|
|
8
|
+
setPreference?: (preference: ThemePreference) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function SliceThemeProvider({ preference, onPreferenceChange, children, }: {
|
|
11
|
+
preference?: ThemePreference;
|
|
12
|
+
onPreferenceChange?: (preference: ThemePreference) => void;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
export declare function useSliceContext(): ThemeContextValue;
|
|
16
|
+
export declare function useSliceTheme(): SliceNativeTheme;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TextStyle, ViewStyle } from 'react-native';
|
|
2
|
-
import { light, coreColors as webCore } from '
|
|
3
|
-
import { corners } from '
|
|
4
|
-
import { elevations } from '
|
|
5
|
-
import { spacing } from '
|
|
6
|
-
import { type as webType } from '
|
|
2
|
+
import { light, coreColors as webCore } from '../../../src/theme/colors/colors';
|
|
3
|
+
import { corners } from '../../../src/theme/corners/corners';
|
|
4
|
+
import { elevations } from '../../../src/theme/elevations/elevations';
|
|
5
|
+
import { spacing } from '../../../src/theme/spacing/spacing';
|
|
6
|
+
import { type as webType } from '../../../src/theme/type/type';
|
|
7
7
|
export { corners, spacing, elevations };
|
|
8
8
|
export type NativeTypography = Record<keyof typeof webType, TextStyle>;
|
|
9
9
|
type ShadowKey = 'surface-shadow-soft' | 'surface-shadow-strong';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { lineHeightTextStyle } from './typography';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { lineHeightTextStyle } from './typography';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TextStyle } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Simple utility to take text style and returns a defined line height factor
|
|
4
|
+
* Since there is no relative/percent in native, looks for the fontsize and
|
|
5
|
+
* derives an absolute line height from the font size
|
|
6
|
+
*/
|
|
7
|
+
export declare function lineHeightTextStyle(styles: TextStyle, lineHeightFactor?: number): TextStyle;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apple-pie/slice-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "React Native icons and design tokens for Slice",
|
|
5
5
|
"author": "Uris Dacosta",
|
|
6
6
|
"license": "ISC",
|
|
@@ -18,19 +18,47 @@
|
|
|
18
18
|
},
|
|
19
19
|
"./package.json": "./package.json",
|
|
20
20
|
"./theme": {
|
|
21
|
-
"types": "./dist/types/native/theme/index.d.ts",
|
|
21
|
+
"types": "./dist/types/native/src/theme/index.d.ts",
|
|
22
22
|
"react-native": "./dist/esm/theme.mjs",
|
|
23
23
|
"import": "./dist/esm/theme.mjs",
|
|
24
24
|
"require": "./dist/cjs/theme.js"
|
|
25
|
+
},
|
|
26
|
+
"./components": {
|
|
27
|
+
"types": "./dist/types/native/src/components/index.d.ts",
|
|
28
|
+
"react-native": "./dist/esm/components.mjs",
|
|
29
|
+
"import": "./dist/esm/components.mjs",
|
|
30
|
+
"require": "./dist/cjs/components.js"
|
|
31
|
+
},
|
|
32
|
+
"./hooks": {
|
|
33
|
+
"types": "./dist/types/native/src/hooks/index.d.ts",
|
|
34
|
+
"react-native": "./dist/esm/hooks.mjs",
|
|
35
|
+
"import": "./dist/esm/hooks.mjs",
|
|
36
|
+
"require": "./dist/cjs/hooks.js"
|
|
37
|
+
},
|
|
38
|
+
"./providers": {
|
|
39
|
+
"types": "./dist/types/native/src/providers/index.d.ts",
|
|
40
|
+
"react-native": "./dist/esm/providers.mjs",
|
|
41
|
+
"import": "./dist/esm/providers.mjs",
|
|
42
|
+
"require": "./dist/cjs/providers.js"
|
|
43
|
+
},
|
|
44
|
+
"./utils": {
|
|
45
|
+
"types": "./dist/types/native/src/utils/index.d.ts",
|
|
46
|
+
"react-native": "./dist/esm/utils.mjs",
|
|
47
|
+
"import": "./dist/esm/utils.mjs",
|
|
48
|
+
"require": "./dist/cjs/utils.js"
|
|
25
49
|
}
|
|
26
50
|
},
|
|
27
51
|
"files": ["dist"],
|
|
28
52
|
"sideEffects": false,
|
|
29
53
|
"scripts": {
|
|
30
54
|
"test": "vitest run --config vitest.config.mts",
|
|
55
|
+
"test:package": "npm run build && node scripts/check-package.mjs",
|
|
56
|
+
"coverage": "vitest run --config vitest.config.mts --coverage",
|
|
31
57
|
"lint": "biome format --write . && biome check . && npm run typecheck",
|
|
32
58
|
"lint:ci": "biome ci . && npm run typecheck",
|
|
33
59
|
"build": "npm run generate && node scripts/build.mjs",
|
|
60
|
+
"pack:tarball": "node scripts/pack.mjs",
|
|
61
|
+
"pack": "node scripts/pack.mjs",
|
|
34
62
|
"prepack": "npm run build",
|
|
35
63
|
"generate": "node scripts/generate-icons.mjs",
|
|
36
64
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
@@ -47,6 +75,7 @@
|
|
|
47
75
|
"peerDependencies": {
|
|
48
76
|
"react": "^18.0.0 || ^19.0.0",
|
|
49
77
|
"react-native": ">=0.80.0 <1.0.0",
|
|
50
|
-
"react-native-svg": "^15.0.0"
|
|
78
|
+
"react-native-svg": "^15.0.0",
|
|
79
|
+
"react-native-reanimated": "^4.0.0"
|
|
51
80
|
}
|
|
52
81
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|