@codeandmoney/soelma 0.0.0-dev.5 → 0.0.0-dev.7

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 (48) hide show
  1. package/appearance/index.d.ts +1 -1
  2. package/appearance/index.js +2 -2
  3. package/appearance/init.js +2 -2
  4. package/context.d.ts +1 -1
  5. package/dark-mode/index.d.ts +1 -1
  6. package/dark-mode/index.js +2 -2
  7. package/dark-mode/init.js +2 -2
  8. package/dimensions/index.js +1 -1
  9. package/dimensions/init.js +2 -2
  10. package/i18n.d.ts +1 -1
  11. package/i18n.js +1 -1
  12. package/index.d.ts +6 -6
  13. package/index.js +4 -4
  14. package/{makeUseStyles/createUseStylesTheme.js → make-use-styles/create-use-styles-theme.js} +22 -5
  15. package/{makeUseStyles/createUseStylesWithoutTheme.js → make-use-styles/create-use-styles-without-theme.js} +16 -7
  16. package/make-use-styles/index.d.ts +20 -0
  17. package/{makeUseStyles → make-use-styles}/index.js +2 -2
  18. package/{makeUseStyles → make-use-styles}/utils.js +5 -10
  19. package/package.json +1 -1
  20. package/safe-area/{eventEmitter.js → event-emitter.js} +1 -1
  21. package/safe-area/index.d.ts +2 -2
  22. package/safe-area/index.js +3 -3
  23. package/safe-area/init.js +2 -2
  24. package/safe-area/{SafeAreaProvider.js → safe-area-provider.js} +2 -2
  25. package/safe-area/state.d.ts +6 -1
  26. package/safe-area/{StylexSaveAreaConsumer.js → stylex-save-area-consumer.js} +1 -1
  27. package/{useColorTransition.d.ts → use-color-transition.d.ts} +1 -1
  28. package/{useColorTransition.js → use-color-transition.js} +1 -1
  29. package/{useTheme.d.ts → use-theme.d.ts} +1 -1
  30. package/{withStyles.js → with-styles.js} +1 -1
  31. package/makeUseStyles/index.d.ts +0 -33
  32. /package/{createEventEmitter.d.ts → create-event-emitter.d.ts} +0 -0
  33. /package/{createEventEmitter.js → create-event-emitter.js} +0 -0
  34. /package/{DefaultTheme.d.ts → default-theme.d.ts} +0 -0
  35. /package/{DefaultTheme.js → default-theme.js} +0 -0
  36. /package/{dependencyRegistry.d.ts → dependency-registry.d.ts} +0 -0
  37. /package/{dependencyRegistry.js → dependency-registry.js} +0 -0
  38. /package/{dependencyUsage.d.ts → dependency-usage.d.ts} +0 -0
  39. /package/{dependencyUsage.js → dependency-usage.js} +0 -0
  40. /package/{makeUseStyles → make-use-styles}/test-type.js +0 -0
  41. /package/{makeUseStyles → make-use-styles}/types.d.ts +0 -0
  42. /package/{makeUseStyles → make-use-styles}/types.js +0 -0
  43. /package/{makeUseStyles → make-use-styles}/types.ts +0 -0
  44. /package/safe-area/{eventEmitter.d.ts → event-emitter.d.ts} +0 -0
  45. /package/safe-area/{SafeAreaProvider.d.ts → safe-area-provider.d.ts} +0 -0
  46. /package/safe-area/{StylexSaveAreaConsumer.d.ts → stylex-save-area-consumer.d.ts} +0 -0
  47. /package/{useTheme.js → use-theme.js} +0 -0
  48. /package/{withStyles.d.ts → with-styles.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import "./init";
2
2
  export type ColorSchemeName = "light" | "dark" | "default";
3
- export declare function appearance<T>({ dark, light, default: defaultScheme, }: {
3
+ export declare function appearance<T>({ dark, light, default: defaultScheme }: {
4
4
  [mode in ColorSchemeName]?: T;
5
5
  }): T | undefined;
6
6
  export declare const darkAppearance: <T>(dark: T) => T | undefined;
@@ -1,8 +1,8 @@
1
1
  import "./init";
2
2
  import { Appearance } from "react-native";
3
- import { onUse } from "../dependencyUsage";
3
+ import { onUse } from "../dependency-usage";
4
4
  import { UI_MODE_DEPENDENCY_KEY } from "./consts";
5
- export function appearance({ dark, light, default: defaultScheme, }) {
5
+ export function appearance({ dark, light, default: defaultScheme }) {
6
6
  onUse(UI_MODE_DEPENDENCY_KEY);
7
7
  // Note: getColorScheme() will always return light when debugging with Chrome.
8
8
  if (Appearance.getColorScheme() === "light") {
@@ -1,6 +1,6 @@
1
1
  import { Appearance } from "react-native";
2
- import { addDependency } from "../dependencyRegistry";
3
- import { createEventEmitter } from "../createEventEmitter";
2
+ import { addDependency } from "../dependency-registry";
3
+ import { createEventEmitter } from "../create-event-emitter";
4
4
  import { UI_MODE_DEPENDENCY_KEY } from "./consts";
5
5
  const { on, emit } = createEventEmitter(UI_MODE_DEPENDENCY_KEY);
6
6
  addDependency(UI_MODE_DEPENDENCY_KEY, (handler) => on(handler));
package/context.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { DefaultTheme } from "./DefaultTheme";
1
+ import { DefaultTheme } from "./default-theme";
2
2
  export declare const themeContext: import("react").Context<DefaultTheme | null>;
3
3
  export declare const ThemeProvider: import("react").Provider<DefaultTheme | null>, ThemeConsumer: import("react").Consumer<DefaultTheme | null>;
@@ -1,6 +1,6 @@
1
1
  import "./init";
2
2
  export type UiType = "dark" | "light";
3
- export declare function uiMode<T>({ dark, light, }: {
3
+ export declare function uiMode<T>({ dark, light }: {
4
4
  [mode in UiType]?: T;
5
5
  }): T | undefined;
6
6
  export declare const darkUiMode: <T>(dark: T) => T | undefined;
@@ -1,8 +1,8 @@
1
1
  import "./init";
2
- import { onUse } from "../dependencyUsage";
2
+ import { onUse } from "../dependency-usage";
3
3
  import { UI_MODE_DEPENDENCY_KEY } from "./consts";
4
4
  import { state } from "./state";
5
- export function uiMode({ dark, light, }) {
5
+ export function uiMode({ dark, light }) {
6
6
  onUse(UI_MODE_DEPENDENCY_KEY);
7
7
  if (state.mode === "dark") {
8
8
  return dark;
package/dark-mode/init.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { eventEmitter } from "react-native-dark-mode";
2
- import { addDependency } from "../dependencyRegistry";
3
- import { createEventEmitter } from "../createEventEmitter";
2
+ import { addDependency } from "../dependency-registry";
3
+ import { createEventEmitter } from "../create-event-emitter";
4
4
  import { UI_MODE_DEPENDENCY_KEY } from "./consts";
5
5
  import { state } from "./state";
6
6
  const { on, emit } = createEventEmitter(UI_MODE_DEPENDENCY_KEY);
@@ -1,6 +1,6 @@
1
1
  import "./init";
2
2
  import { Dimensions } from "react-native";
3
- import { onUse } from "../dependencyUsage";
3
+ import { onUse } from "../dependency-usage";
4
4
  import { WINDOW_DEPENDENCY_KEY, SCREEN_DEPENDENCY_KEY } from "./consts";
5
5
  const get = (dim) => Dimensions.get(dim);
6
6
  export function getWindowDimensions() {
@@ -1,6 +1,6 @@
1
1
  import { Dimensions } from "react-native";
2
- import { createEventEmitter } from "../createEventEmitter";
3
- import { addDependency } from "../dependencyRegistry";
2
+ import { createEventEmitter } from "../create-event-emitter";
3
+ import { addDependency } from "../dependency-registry";
4
4
  import { SCREEN_DEPENDENCY_KEY, WINDOW_DEPENDENCY_KEY } from "./consts";
5
5
  const { get, addEventListener } = Dimensions;
6
6
  const state = { window: get("window"), screen: get("screen") };
package/i18n.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  type LayoutDirectionType = "rtl" | "ltr";
2
- export declare function i18n<T>({ rtl, ltr, }: {
2
+ export declare function i18n<T>({ rtl, ltr }: {
3
3
  [direction in LayoutDirectionType]?: T;
4
4
  }): T | undefined;
5
5
  export declare const rtl: <T>(styles: T) => T | undefined;
package/i18n.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { I18nManager } from "react-native";
2
- export function i18n({ rtl, ltr, }) {
2
+ export function i18n({ rtl, ltr }) {
3
3
  if (I18nManager.isRTL) {
4
4
  return rtl;
5
5
  }
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { useTheme } from "./useTheme";
2
- export { withStyles } from "./withStyles";
1
+ export { useTheme } from "./use-theme";
2
+ export { withStyles } from "./with-styles";
3
3
  export { ThemeProvider, ThemeConsumer } from "./context";
4
- export { useColorTransition } from "./useColorTransition";
5
- export { makeUseStyles } from "./makeUseStyles";
6
- export type { DefaultTheme } from "./DefaultTheme";
7
- export type { InferInjectedStyledProps } from "./withStyles";
4
+ export { useColorTransition } from "./use-color-transition";
5
+ export { makeUseStyles } from "./make-use-styles";
6
+ export type { DefaultTheme } from "./default-theme";
7
+ export type { InferInjectedStyledProps } from "./with-styles";
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { useTheme } from "./useTheme";
2
- export { withStyles } from "./withStyles";
1
+ export { useTheme } from "./use-theme";
2
+ export { withStyles } from "./with-styles";
3
3
  export { ThemeProvider, ThemeConsumer } from "./context";
4
- export { useColorTransition } from "./useColorTransition";
5
- export { makeUseStyles } from "./makeUseStyles";
4
+ export { useColorTransition } from "./use-color-transition";
5
+ export { makeUseStyles } from "./make-use-styles";
@@ -1,9 +1,9 @@
1
1
  import { StyleSheet } from "react-native";
2
- import { useTheme } from "../useTheme";
3
- import { resetUsing } from "../dependencyUsage";
2
+ import { useTheme } from "../use-theme";
3
+ import { resetUsing } from "../dependency-usage";
4
4
  import { getDependenciesKeys, useForceUpdate, subscribe } from "./utils";
5
5
 
6
- export function createUseStylesTheme(getStyles) {
6
+ export function createUseStylesTheme(getStyles, getVariants) {
7
7
  const scope = {
8
8
  styles: new WeakMap(),
9
9
  forceUpdate: [],
@@ -28,7 +28,7 @@ export function createUseStylesTheme(getStyles) {
28
28
  return style;
29
29
  }
30
30
 
31
- return function useStyles() {
31
+ function useStyles(variants) {
32
32
  const theme = useTheme();
33
33
 
34
34
  useForceUpdate(scope);
@@ -37,6 +37,23 @@ export function createUseStylesTheme(getStyles) {
37
37
  scope.styles.set(theme, initStyle(theme));
38
38
  }
39
39
 
40
+ if (getVariants) {
41
+ const configVariants = getVariants(theme);
42
+ const requestedVarians = {};
43
+
44
+ for (const key in variants) {
45
+ const value = configVariants[key][variants[key]];
46
+ Object.assign(requestedVarians, value);
47
+ }
48
+
49
+ return {
50
+ ...scope.styles.get(theme),
51
+ ...StyleSheet.create({ variants: requestedVarians }),
52
+ };
53
+ }
54
+
40
55
  return scope.styles.get(theme);
41
- };
56
+ }
57
+
58
+ return useStyles;
42
59
  }
@@ -1,8 +1,8 @@
1
1
  import { StyleSheet } from "react-native";
2
- import { resetUsing } from "../dependencyUsage";
2
+ import { resetUsing } from "../dependency-usage";
3
3
  import { getDependenciesKeys, subscribe, useForceUpdate } from "./utils";
4
4
 
5
- export function createUseStylesWithoutTheme(getStyles, configVariants) {
5
+ export function createUseStylesWithoutTheme(getStyles, getVariants) {
6
6
  const scope = {
7
7
  style: null,
8
8
  variants: null,
@@ -32,13 +32,22 @@ export function createUseStylesWithoutTheme(getStyles, configVariants) {
32
32
  function useStyles(variants) {
33
33
  useForceUpdate(scope);
34
34
 
35
- const requestedVarians = {};
36
- for (const key in variants) {
37
- const value = configVariants[key][variants[key]];
38
- Object.assign(requestedVarians, value);
35
+ if (getVariants) {
36
+ const configVariants = getVariants();
37
+ const requestedVarians = {};
38
+
39
+ for (const key in variants) {
40
+ const value = configVariants[key][variants[key]];
41
+ Object.assign(requestedVarians, value);
42
+ }
43
+
44
+ return {
45
+ ...scope.style,
46
+ ...StyleSheet.create({ variants: requestedVarians }),
47
+ };
39
48
  }
40
49
 
41
- return { ...scope.style, ...StyleSheet.create({ variants: requestedVarians}) };
50
+ return scope.style;
42
51
  }
43
52
 
44
53
  return useStyles;
@@ -0,0 +1,20 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { DefaultTheme } from "../default-theme";
3
+
4
+ export function makeUseStyles<
5
+ Theme extends DefaultTheme,
6
+ T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>,
7
+ VariantsConfig extends Record<string, StyleSheet.NamedStyles<any>> | undefined = undefined,
8
+ >(
9
+ getStyles: (theme: Theme) => T | StyleSheet.NamedStyles<T>,
10
+ getVariants?: ((theme: Theme) => VariantsConfig) | undefined,
11
+ ): <Variants extends { [Key in keyof VariantsConfig]: keyof VariantsConfig[Key] }>(
12
+ variants?: Partial<Variants>,
13
+ ) => T &
14
+ (VariantsConfig extends undefined
15
+ ? {}
16
+ : {
17
+ variants: {
18
+ [VKey in keyof Variants]: VKey extends keyof VariantsConfig ? VariantsConfig[VKey][Variants[VKey]] : never;
19
+ }[keyof Variants];
20
+ });
@@ -1,5 +1,5 @@
1
- import { createUseStylesWithoutTheme } from "./createUseStylesWithoutTheme";
2
- import { createUseStylesTheme } from "./createUseStylesTheme";
1
+ import { createUseStylesWithoutTheme } from "./create-use-styles-without-theme";
2
+ import { createUseStylesTheme } from "./create-use-styles-theme";
3
3
 
4
4
  export function makeUseStyles(getStyles, variants) {
5
5
  const hasThemeDependency = getStyles.length === 1;
@@ -1,6 +1,6 @@
1
1
  import { optimizeDependencies } from "../dimensions/utils";
2
- import { getUsing } from "../dependencyUsage";
3
- import { getDependency } from "../dependencyRegistry";
2
+ import { getUsing } from "../dependency-usage";
3
+ import { getDependency } from "../dependency-registry";
4
4
 
5
5
  import { useEffect, useRef, useState } from "react";
6
6
 
@@ -17,9 +17,7 @@ export const useForceUpdate = (scope) => {
17
17
  scope.forceUpdate = scope.forceUpdate.concat(forceRerender);
18
18
 
19
19
  unsubscribeRef.current = () => {
20
- scope.forceUpdate = scope.forceUpdate.filter(
21
- (fn) => fn !== forceRerender,
22
- );
20
+ scope.forceUpdate = scope.forceUpdate.filter((fn) => fn !== forceRerender);
23
21
  };
24
22
  }
25
23
 
@@ -32,8 +30,7 @@ export const useForceUpdate = (scope) => {
32
30
  );
33
31
  };
34
32
 
35
- export const getDependenciesKeys = () =>
36
- Object.keys(optimizeDependencies(getUsing())).sort();
33
+ export const getDependenciesKeys = () => Object.keys(optimizeDependencies(getUsing())).sort();
37
34
 
38
35
  export const subscribe = (dependenciesKeys, handler) => {
39
36
  if (dependenciesKeys.length === 0) {
@@ -50,9 +47,7 @@ export const subscribe = (dependenciesKeys, handler) => {
50
47
  const dependencyName = dependenciesKeys[index];
51
48
 
52
49
  if (!onChange) {
53
- console.warn(
54
- `[react-native-stylex] Could not find onChange handler for ${dependencyName}!`,
55
- );
50
+ console.warn(`[react-native-stylex] Could not find onChange handler for ${dependencyName}!`);
56
51
  }
57
52
 
58
53
  return !!onChange;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.0.0-dev.5",
6
+ "version": "0.0.0-dev.7",
7
7
  "private": false,
8
8
  "main": "index.js",
9
9
  "types": "index.d.ts",
@@ -1,3 +1,3 @@
1
- import { createEventEmitter } from "../createEventEmitter";
1
+ import { createEventEmitter } from "../create-event-emitter";
2
2
  import { SAFE_AREA_DEPENDENCY_KEY } from "./consts";
3
3
  export const { emit, on } = createEventEmitter(SAFE_AREA_DEPENDENCY_KEY);
@@ -1,5 +1,5 @@
1
1
  import "./init";
2
2
  import { EdgeInsets } from "./types";
3
- export { StylexSaveAreaConsumer } from "./StylexSaveAreaConsumer";
4
- export { SafeAreaProvider } from "./SafeAreaProvider";
3
+ export { StylexSaveAreaConsumer } from "./stylex-save-area-consumer";
4
+ export { SafeAreaProvider } from "./safe-area-provider";
5
5
  export declare function getSafeArea(): EdgeInsets;
@@ -1,9 +1,9 @@
1
1
  import "./init";
2
- import { onUse } from "../dependencyUsage";
2
+ import { onUse } from "../dependency-usage";
3
3
  import { SAFE_AREA_DEPENDENCY_KEY } from "./consts";
4
4
  import { state } from "./state";
5
- export { StylexSaveAreaConsumer } from "./StylexSaveAreaConsumer";
6
- export { SafeAreaProvider } from "./SafeAreaProvider";
5
+ export { StylexSaveAreaConsumer } from "./stylex-save-area-consumer";
6
+ export { SafeAreaProvider } from "./safe-area-provider";
7
7
  export function getSafeArea() {
8
8
  onUse(SAFE_AREA_DEPENDENCY_KEY);
9
9
  return state.insets;
package/safe-area/init.js CHANGED
@@ -1,4 +1,4 @@
1
- import { addDependency } from "../dependencyRegistry";
1
+ import { addDependency } from "../dependency-registry";
2
2
  import { SAFE_AREA_DEPENDENCY_KEY } from "./consts";
3
- import { on } from "./eventEmitter";
3
+ import { on } from "./event-emitter";
4
4
  addDependency(SAFE_AREA_DEPENDENCY_KEY, (handler) => on(handler));
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import { SafeAreaProvider as CoreSafeAreaProvider, initialWindowMetrics, initialWindowSafeAreaInsets, } from "react-native-safe-area-context";
3
- import { StylexSaveAreaConsumer } from "./StylexSaveAreaConsumer";
2
+ import { SafeAreaProvider as CoreSafeAreaProvider, initialWindowMetrics, initialWindowSafeAreaInsets } from "react-native-safe-area-context";
3
+ import { StylexSaveAreaConsumer } from "./stylex-save-area-consumer";
4
4
  export function SafeAreaProvider(props) {
5
5
  return (<CoreSafeAreaProvider initialSafeAreaInsets={props.initialSafeAreaInsets || initialWindowSafeAreaInsets} initialMetrics={props.initialMetrics || initialWindowMetrics} {...props}>
6
6
  {props.children}
@@ -1,3 +1,8 @@
1
1
  export declare const state: {
2
- insets: import("react-native-safe-area-context").EdgeInsets;
2
+ insets: {
3
+ top: number;
4
+ left: number;
5
+ bottom: number;
6
+ right: number;
7
+ };
3
8
  };
@@ -1,5 +1,5 @@
1
1
  import { useSafeAreaInsets } from "react-native-safe-area-context";
2
- import { emit } from "./eventEmitter";
2
+ import { emit } from "./event-emitter";
3
3
  import { state } from "./state";
4
4
  import { useLayoutEffect } from "react";
5
5
  export function StylexSaveAreaConsumer() {
@@ -1,5 +1,5 @@
1
1
  import { Animated } from "react-native";
2
- import { DefaultTheme } from "./DefaultTheme";
2
+ import { DefaultTheme } from "./default-theme";
3
3
  export declare function useColorTransition<Theme = DefaultTheme>(colorGetterFn: (theme: Theme) => string, options?: {
4
4
  duration: number;
5
5
  }): Animated.AnimatedInterpolation<string>;
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useMemo, useRef } from "react";
2
2
  import { Animated } from "react-native";
3
- import { useTheme } from "./useTheme";
3
+ import { useTheme } from "./use-theme";
4
4
  const { Value, timing } = Animated;
5
5
  const INITIAL_VALUE = 0;
6
6
  const defaultOptions = { duration: 250 };
@@ -1,2 +1,2 @@
1
- import type { DefaultTheme } from "./DefaultTheme";
1
+ import type { DefaultTheme } from "./default-theme";
2
2
  export declare const useTheme: <Theme = DefaultTheme>() => Theme;
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, } from "react";
1
+ import React, { forwardRef } from "react";
2
2
  export function withStyles(useStyles) {
3
3
  function WithStyles(Component) {
4
4
  const renderComponent = (props, ref) => {
@@ -1,33 +0,0 @@
1
- import { StyleSheet } from "react-native";
2
- import { DefaultTheme } from "../DefaultTheme";
3
-
4
- // export function makeUseStyles<
5
- // Theme extends DefaultTheme,
6
- // T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>,
7
- // V extends Record<
8
- // string,
9
- // StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>
10
- // >,
11
- // >(
12
- // getStyles: (theme: Theme) => T | StyleSheet.NamedStyles<T>,
13
- // variants: V,
14
- // ): () => T;
15
-
16
- export function makeUseStyles<
17
- Theme extends DefaultTheme,
18
- T extends StyleSheet.NamedStyles<T> | StyleSheet.NamedStyles<any>,
19
- V extends Record<string, StyleSheet.NamedStyles<any>>,
20
- >(
21
- getStyles: (theme: Theme) => T | StyleSheet.NamedStyles<T>,
22
- variants: V,
23
- ): <Variants extends { [Key in keyof V]: keyof V[Key] }>(
24
- variants?: Partial<Variants>,
25
- ) => T & {
26
- variants: {
27
- [VKey in keyof Variants]: VKey extends keyof V
28
- ? V[VKey][Variants[VKey]]
29
- : never;
30
- }[keyof Variants];
31
- } {
32
- return ((variants: any) => {}) as any;
33
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes