@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.
Files changed (74) hide show
  1. package/README.md +196 -6
  2. package/dist/cjs/components.js +15 -0
  3. package/dist/cjs/hooks.js +7 -0
  4. package/dist/cjs/index.js +18 -805
  5. package/dist/cjs/providers.js +9 -0
  6. package/dist/cjs/src/components/SliceButton/SliceButton.js +119 -0
  7. package/dist/cjs/src/components/SliceIcon/SliceIcon.js +20 -0
  8. package/dist/cjs/src/components/SliceIcon/iconRegistry.js +668 -0
  9. package/dist/cjs/src/components/SliceIcon/icons.js +144 -0
  10. package/dist/cjs/src/components/SliceText/SliceText.js +21 -0
  11. package/dist/cjs/src/components/SliceTextInput/SliceTextInput.js +87 -0
  12. package/dist/cjs/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +13 -0
  13. package/dist/cjs/src/providers/SliceThemeProvider.js +37 -0
  14. package/dist/cjs/src/theme/colors/colors.js +253 -0
  15. package/dist/cjs/src/theme/corners/corners.js +14 -0
  16. package/dist/cjs/src/theme/elevations/elevations.js +17 -0
  17. package/dist/cjs/src/theme/motion/motion.js +15 -0
  18. package/dist/cjs/src/theme/motion.js +47 -0
  19. package/dist/cjs/src/theme/spacing/spacing.js +14 -0
  20. package/dist/cjs/src/theme/type/type.js +190 -0
  21. package/dist/cjs/src/utils/typography/typography.js +17 -0
  22. package/dist/cjs/theme.js +23 -538
  23. package/dist/cjs/utils.js +7 -0
  24. package/dist/esm/components.mjs +5 -0
  25. package/dist/esm/hooks.mjs +1 -0
  26. package/dist/esm/index.mjs +8 -806
  27. package/dist/esm/providers.mjs +1 -0
  28. package/dist/esm/src/components/SliceButton/SliceButton.mjs +117 -0
  29. package/dist/esm/src/components/SliceIcon/SliceIcon.mjs +18 -0
  30. package/dist/esm/src/components/SliceIcon/iconRegistry.mjs +666 -0
  31. package/dist/esm/src/components/SliceIcon/icons.mjs +142 -0
  32. package/dist/esm/src/components/SliceText/SliceText.mjs +19 -0
  33. package/dist/esm/src/components/SliceTextInput/SliceTextInput.mjs +85 -0
  34. package/dist/esm/src/hooks/useCreateThemedStyles/useCreateThemedStyles.mjs +11 -0
  35. package/dist/esm/src/providers/SliceThemeProvider.mjs +33 -0
  36. package/dist/esm/src/theme/colors/colors.mjs +249 -0
  37. package/dist/esm/src/theme/corners/corners.mjs +12 -0
  38. package/dist/esm/src/theme/elevations/elevations.mjs +15 -0
  39. package/dist/esm/src/theme/motion/motion.mjs +13 -0
  40. package/dist/esm/src/theme/motion.mjs +45 -0
  41. package/dist/esm/src/theme/spacing/spacing.mjs +12 -0
  42. package/dist/esm/src/theme/type/type.mjs +184 -0
  43. package/dist/esm/src/utils/typography/typography.mjs +15 -0
  44. package/dist/esm/theme.mjs +7 -522
  45. package/dist/esm/utils.mjs +1 -0
  46. package/dist/types/native/index.d.ts +8 -4
  47. package/dist/types/native/src/components/SliceButton/SliceButton.d.ts +5 -0
  48. package/dist/types/native/src/components/SliceButton/_types.d.ts +47 -0
  49. package/dist/types/native/src/components/SliceButton/index.d.ts +2 -0
  50. package/dist/types/native/src/components/SliceIcon/SliceIcon.d.ts +2 -0
  51. package/dist/types/native/{components/Icon → src/components/SliceIcon}/icons.d.ts +2 -0
  52. package/dist/types/native/src/components/SliceIcon/index.d.ts +3 -0
  53. package/dist/types/native/src/components/SliceText/SliceText.d.ts +5 -0
  54. package/dist/types/native/src/components/SliceText/_types.d.ts +17 -0
  55. package/dist/types/native/src/components/SliceText/index.d.ts +2 -0
  56. package/dist/types/native/src/components/SliceTextInput/SliceTextInput.d.ts +2 -0
  57. package/dist/types/native/src/components/SliceTextInput/_types.d.ts +36 -0
  58. package/dist/types/native/src/components/SliceTextInput/index.d.ts +2 -0
  59. package/dist/types/native/src/components/index.d.ts +8 -0
  60. package/dist/types/native/src/hooks/index.d.ts +1 -0
  61. package/dist/types/native/src/hooks/useCreateThemedStyles/index.d.ts +1 -0
  62. package/dist/types/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.d.ts +7 -0
  63. package/dist/types/native/src/providers/SliceThemeProvider.d.ts +16 -0
  64. package/dist/types/native/src/providers/index.d.ts +2 -0
  65. package/dist/types/native/{theme → src/theme}/index.d.ts +5 -5
  66. package/dist/types/native/src/utils/index.d.ts +1 -0
  67. package/dist/types/native/src/utils/typography/index.d.ts +1 -0
  68. package/dist/types/native/src/utils/typography/typography.d.ts +7 -0
  69. package/package.json +32 -3
  70. package/dist/types/native/components/Icon/NativeIcon.d.ts +0 -2
  71. package/dist/types/native/components/Icon/index.d.ts +0 -3
  72. /package/dist/types/native/{components/Icon → src/components/SliceIcon}/_types.d.ts +0 -0
  73. /package/dist/types/native/{components/Icon → src/components/SliceIcon}/iconRegistry.d.ts +0 -0
  74. /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,2 @@
1
+ export { SliceTextInput } from './SliceTextInput';
2
+ export type { SliceTextInputProps } from './_types';
@@ -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;
@@ -0,0 +1,2 @@
1
+ export { SliceThemeProvider, useSliceTheme, useSliceContext } from './SliceThemeProvider';
2
+ export type { ThemePreference, ThemeContextValue } from './SliceThemeProvider';
@@ -1,9 +1,9 @@
1
1
  import type { TextStyle, ViewStyle } from 'react-native';
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';
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",
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
  }
@@ -1,2 +0,0 @@
1
- import type { IconProps } from './_types';
2
- export declare const NativeIcon: import("react").MemoExoticComponent<(props: IconProps) => import("react").JSX.Element | null>;
@@ -1,3 +0,0 @@
1
- export { NativeIcon, NativeIcon as Icon } from './NativeIcon';
2
- export type { IconProps } from './_types';
3
- export { SliceIcons } from './icons';