app-studio 0.7.18 → 0.8.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.
Files changed (114) hide show
  1. package/README.md +87 -33
  2. package/dist/native/index.cjs +3360 -0
  3. package/dist/native/index.cjs.map +1 -0
  4. package/dist/native/index.d.mts +251 -0
  5. package/dist/native/index.d.ts +251 -0
  6. package/dist/native/index.js +3268 -0
  7. package/dist/native/index.js.map +1 -0
  8. package/dist/viewAnimation-B4BIoOwQ.d.mts +2246 -0
  9. package/dist/viewAnimation-B4BIoOwQ.d.ts +2246 -0
  10. package/dist/web/app-studio.umd.production.min.global.js +28 -0
  11. package/dist/web/app-studio.umd.production.min.global.js.map +1 -0
  12. package/dist/web/index.cjs +6109 -0
  13. package/dist/web/index.cjs.map +1 -0
  14. package/dist/web/index.d.mts +638 -0
  15. package/dist/web/index.d.ts +638 -0
  16. package/dist/web/index.js +6008 -0
  17. package/dist/web/index.js.map +1 -0
  18. package/docs/Animation.md +2 -0
  19. package/docs/Components.md +12 -0
  20. package/docs/Design.md +2 -0
  21. package/docs/Events.md +2 -0
  22. package/docs/Hooks.md +2 -0
  23. package/docs/IframeSupport.md +2 -0
  24. package/docs/Native.md +428 -0
  25. package/docs/Providers.md +2 -0
  26. package/docs/README.md +14 -1
  27. package/docs/Responsive.md +2 -0
  28. package/docs/Styling.md +2 -0
  29. package/docs/Theming.md +53 -0
  30. package/package.json +76 -14
  31. package/dist/app-studio.cjs.development.js +0 -6754
  32. package/dist/app-studio.cjs.development.js.map +0 -1
  33. package/dist/app-studio.cjs.production.min.js +0 -2
  34. package/dist/app-studio.cjs.production.min.js.map +0 -1
  35. package/dist/app-studio.esm.js +0 -6650
  36. package/dist/app-studio.esm.js.map +0 -1
  37. package/dist/app-studio.umd.development.js +0 -6757
  38. package/dist/app-studio.umd.development.js.map +0 -1
  39. package/dist/app-studio.umd.production.min.js +0 -2
  40. package/dist/app-studio.umd.production.min.js.map +0 -1
  41. package/dist/components/Form.d.ts +0 -17
  42. package/dist/components/Image.d.ts +0 -7
  43. package/dist/components/Skeleton.d.ts +0 -3
  44. package/dist/components/Text/Text.props.d.ts +0 -27
  45. package/dist/components/Text/Text.type.d.ts +0 -3
  46. package/dist/components/Text/Text.utils.d.ts +0 -2
  47. package/dist/components/Text/Text.view.d.ts +0 -20
  48. package/dist/components/Text.d.ts +0 -5
  49. package/dist/components/View.d.ts +0 -16
  50. package/dist/components/Wrapper.d.ts +0 -4
  51. package/dist/element/Animation.d.ts +0 -1164
  52. package/dist/element/Element.d.ts +0 -4
  53. package/dist/element/Element.types.d.ts +0 -123
  54. package/dist/element/css.d.ts +0 -50
  55. package/dist/element/utils.d.ts +0 -4
  56. package/dist/hooks/useActive.d.ts +0 -2
  57. package/dist/hooks/useClickOutside.d.ts +0 -6
  58. package/dist/hooks/useElementPosition.d.ts +0 -39
  59. package/dist/hooks/useFocus.d.ts +0 -2
  60. package/dist/hooks/useHover.d.ts +0 -2
  61. package/dist/hooks/useIframeStyles.d.ts +0 -41
  62. package/dist/hooks/useInView.d.ts +0 -11
  63. package/dist/hooks/useKeyPress.d.ts +0 -1
  64. package/dist/hooks/useMount.d.ts +0 -1
  65. package/dist/hooks/useOnScreen.d.ts +0 -6
  66. package/dist/hooks/useResponsive.d.ts +0 -59
  67. package/dist/hooks/useScroll.d.ts +0 -49
  68. package/dist/hooks/useWindowSize.d.ts +0 -4
  69. package/dist/index.d.ts +0 -33
  70. package/dist/index.js +0 -8
  71. package/dist/providers/Analytics.d.ts +0 -9
  72. package/dist/providers/Responsive.d.ts +0 -58
  73. package/dist/providers/StyleRegistry.d.ts +0 -32
  74. package/dist/providers/Theme.d.ts +0 -46
  75. package/dist/providers/WindowSize.d.ts +0 -11
  76. package/dist/stories/AnimateOn.stories.d.ts +0 -30
  77. package/dist/stories/Animation.stories.d.ts +0 -35
  78. package/dist/stories/BorderColor.stories.d.ts +0 -4
  79. package/dist/stories/Color.stories.d.ts +0 -4
  80. package/dist/stories/ColorAlpha.stories.d.ts +0 -5
  81. package/dist/stories/Component.stories.d.ts +0 -7
  82. package/dist/stories/CrossBrowserCompatibility.stories.d.ts +0 -6
  83. package/dist/stories/CssCascadeOrder.stories.d.ts +0 -10
  84. package/dist/stories/EmptyBeforeExample.stories.d.ts +0 -7
  85. package/dist/stories/EventHandlers.stories.d.ts +0 -6
  86. package/dist/stories/GradientColors.stories.d.ts +0 -6
  87. package/dist/stories/GroupPeer.stories.d.ts +0 -7
  88. package/dist/stories/Hooks.stories.d.ts +0 -17
  89. package/dist/stories/IframeCSSSupport.stories.d.ts +0 -28
  90. package/dist/stories/IframeSupport.stories.d.ts +0 -20
  91. package/dist/stories/Image.stories.d.ts +0 -6
  92. package/dist/stories/Scroll.stories.d.ts +0 -9
  93. package/dist/stories/ScrollAnimation.stories.d.ts +0 -36
  94. package/dist/stories/ScrollTimeline.stories.d.ts +0 -6
  95. package/dist/stories/Skeleton.stories.d.ts +0 -5
  96. package/dist/stories/Text.stories.d.ts +0 -18
  97. package/dist/stories/VendorPrefix.stories.d.ts +0 -6
  98. package/dist/stories/View.stories.d.ts +0 -10
  99. package/dist/stories/ViewAnimation.stories.d.ts +0 -33
  100. package/dist/test/CssVariablesTest.d.ts +0 -3
  101. package/dist/test/LowercaseVendorPrefixTest.d.ts +0 -3
  102. package/dist/test/VendorPrefixTest.d.ts +0 -3
  103. package/dist/test/WebkitTextStrokeTest.d.ts +0 -3
  104. package/dist/types/scrollAnimation.types.d.ts +0 -75
  105. package/dist/utils/colors.d.ts +0 -21
  106. package/dist/utils/constants.d.ts +0 -24
  107. package/dist/utils/cssProperties.d.ts +0 -8
  108. package/dist/utils/env.d.ts +0 -15
  109. package/dist/utils/hash.d.ts +0 -4
  110. package/dist/utils/shadow.d.ts +0 -10
  111. package/dist/utils/style.d.ts +0 -22
  112. package/dist/utils/typography.d.ts +0 -45
  113. package/dist/utils/vendorPrefixes.d.ts +0 -19
  114. package/dist/utils/viewAnimation.d.ts +0 -138
package/README.md CHANGED
@@ -12,6 +12,7 @@ App-Studio is a React library designed to streamline the development of modern w
12
12
  * **Animation System:** A declarative `Animation` object for easily applying and sequencing CSS animations and transitions, including scroll-driven effects.
13
13
  * **Helpful Hooks:** A collection of hooks for managing state, detecting interactions (`useHover`, `useActive`, `useFocus`), tracking viewport status (`useInView`, `useOnScreen`), handling events (`useClickOutside`, `useKeyPress`), and more.
14
14
  * **Analytics Integration:** `AnalyticsProvider` to easily integrate event tracking.
15
+ * **React Native Support:** A dedicated native build ships alongside the web build. Metro picks it automatically through the `react-native` export condition — the same import paths and prop API work on iOS, Android, and web, with web-only props (`_hover`, pseudo-elements, CSS animations) accepted as no-ops on native.
15
16
  * **TypeScript Support:** Fully typed for a better development experience.
16
17
 
17
18
  ---
@@ -71,6 +72,63 @@ Get started with App-Studio by installing it via npm and setting up the necessar
71
72
  export default App;
72
73
  ```
73
74
 
75
+ ### React Native
76
+
77
+ The same package name works in React Native 0.79+ through Metro package exports:
78
+
79
+ ```tsx
80
+ import { View, Text, Button, ThemeProvider, ResponsiveProvider } from 'app-studio';
81
+ ```
82
+
83
+ Metro resolves `app-studio` to the native build automatically. The explicit `app-studio/native` and `app-studio/web` subpaths are also available for debugging or tooling. Native supports the cross-platform primitives and providers; web-only styling props such as `_hover`, pseudo-elements, CSS animations, and HTML `as` values are accepted as no-ops in React Native.
84
+
85
+ A typical RN entrypoint looks identical to the web one — same providers, same import paths:
86
+
87
+ ```tsx
88
+ import React from 'react';
89
+ import {
90
+ ThemeProvider,
91
+ ResponsiveProvider,
92
+ WindowSizeProvider,
93
+ View,
94
+ Text,
95
+ Button,
96
+ } from 'app-studio';
97
+
98
+ export default function App() {
99
+ return (
100
+ <ThemeProvider>
101
+ <WindowSizeProvider>
102
+ <ResponsiveProvider>
103
+ <View padding={20} backgroundColor="theme-primary" widthHeight="100%">
104
+ <Text color="color-white" fontSize={20} fontWeight="bold" maxLines={1}>
105
+ Hello, native!
106
+ </Text>
107
+ <Button
108
+ marginTop={16}
109
+ paddingHorizontal={20}
110
+ paddingVertical={12}
111
+ backgroundColor="color-white"
112
+ borderRadius={8}
113
+ shadow={0.3}
114
+ onPress={() => console.log('Pressed')}
115
+ >
116
+ <Text color="theme-primary" fontWeight="bold">Press me</Text>
117
+ </Button>
118
+ </View>
119
+ </ResponsiveProvider>
120
+ </WindowSizeProvider>
121
+ </ThemeProvider>
122
+ );
123
+ }
124
+ ```
125
+
126
+ **What carries over from web:** direct style props, the `media` map, theme/palette color strings (`theme-primary`, `color-blue-500`, `light-white`, `dark-red-200`, alpha shorthand like `theme-primary-300`), the `widthHeight` and `shadow` shorthands, `data-testid` (rewritten to `testID`), `aria-label` (rewritten to `accessibilityLabel`), all four providers, and the `useResponsive` / `useWindowSize` / `useBreakpoint` / `useTheme` hooks.
127
+
128
+ **What's web-only on native (silently dropped):** state modifiers (`_hover`, `_focus`, `_active`, `_disabled`, …), pseudo-elements (`_before`, `_after`, …), the `on={{ hover, focus, ... }}` map, raw-string `css`, the `as` prop, `className`, and the `Animation.*` / `animate` system. Hooks that depend on DOM APIs (`useHover`, `useFocus`, `useClickOutside`, `useScroll`, `useInView`, `useOnScreen`, `useElementPosition`, `useKeyPress`, `useIframeStyles`) are exported as safe stubs so shared component code keeps compiling — but you should branch when meaningful interaction state is needed.
129
+
130
+ For the full component mapping table, native-only props, per-hook breakdown, and a side-by-side web/native cheat sheet, see [docs/Native.md](docs/Native.md).
131
+
74
132
  ---
75
133
 
76
134
  # Core Concepts
@@ -271,7 +329,9 @@ function MyStyledElement() {
271
329
  }
272
330
  ```
273
331
 
274
- In addition to global theming via `ThemeProvider`, the `Element` component offers granular control through the `themeMode`, `colors`, and `theme` props. When specified, these props locally override the context provided by `ThemeProvider` for this specific element instance and how its style props (like `backgroundColor="theme-primary"` or `color="color-blue-500"`) resolve color values. `themeMode` forces 'light' or 'dark' mode resolution, `colors` provides a custom `{ main, palette }` object, and `theme` supplies custom token mappings (e.g., `{ primary: 'color-purple-500' }`). This allows creating distinctly styled sections or components without altering the global theme, useful for sidebars, specific UI states, or component variations.
332
+ In addition to global theming via `ThemeProvider`, every component that extends `Element` (`View`, `Text`, `Button`, etc.) accepts a `theme` prop that remaps `theme-*` tokens **for that single component**, without altering the global theme. This is useful for creating distinctly styled sections or one-off branded components (a launch button, a callout card, a status chip) while the rest of the UI keeps the global palette.
333
+
334
+ The `theme` prop takes a `Partial<Theme>` mapping any of the global theme slots (`primary`, `secondary`, `success`, `error`, `warning`, `disabled`, `loading`) to another color token (`'color-red-500'`, `'theme-secondary'`) or a raw color string (`'#ff0000'`). See [docs/Theming.md](docs/Theming.md#component-level-sub-theming) for the full reference, including dark-mode behavior and scope caveats.
275
335
 
276
336
  **Example (Local Theme Override):**
277
337
 
@@ -279,35 +339,21 @@ In addition to global theming via `ThemeProvider`, the `Element` component offer
279
339
  import { Element, Text } from 'app-studio';
280
340
 
281
341
  function LocallyThemedSection() {
282
- // Assume the global theme is currently 'light' mode.
283
-
284
- // Define a local override theme and colors for this specific section
285
- const localThemeOverride = { primary: 'color-orange-500', secondary: 'color-teal-300' };
286
- const localDarkColorsOverride = {
287
- main: {
288
- white: '#EEE'
289
- }
290
- }; // Using defaults for demonstration
291
-
292
342
  return (
293
343
  <Element
294
344
  padding={20}
295
345
  marginVertical={10}
296
- // Force dark mode and provide specific theme/color definitions JUST for this Element
297
- themeMode="dark"
298
- theme={localThemeOverride}
299
- colors={localDarkColorsOverride}
300
- // Styles below will resolve using the LOCAL dark theme override defined above:
301
- backgroundColor="theme-secondary" // Resolves to 'color-teal-300' via localThemeOverride in dark mode
346
+ // Remap theme-primary / theme-secondary just for this Element:
347
+ theme={{ primary: 'color-orange-500', secondary: 'color-teal-300' }}
348
+ backgroundColor="theme-secondary" // -> color-teal-300
349
+ borderColor="theme-primary" // -> color-orange-500
350
+ borderWidth={2}
351
+ borderStyle="solid"
302
352
  borderRadius={8}
303
353
  >
304
- <Text color="color-white"
305
- colors={localDarkColorsOverride}> {/* 'color-white' from localDarkColorsOverride.main */}
306
- This section forces dark mode with an orange primary, even if the app is light-
354
+ <Text color="color-white">
355
+ This section uses an orange primary, even though the global theme is unchanged.
307
356
  </Text>
308
- <Element marginTop={8} padding={10} backgroundColor="color-gray-700"> {/* Uses local dark palette */}
309
- <Text color="theme-primary">Nested Primary (Orange)</Text> {/* Still uses local override */}
310
- </Element>
311
357
  </Element>
312
358
  );
313
359
  }
@@ -729,18 +775,25 @@ Manages the application's theme, including color palettes, light/dark modes, and
729
775
 
730
776
  **Props:**
731
777
 
732
- | Prop | Type | Default | Description |
733
- | :------ | :----------------- | :---------------------------------- | :-------------------------------------------------------------------------------- |
734
- | `theme` | `object` | `{ primary: 'color-black', ... }` | Custom theme tokens (e.g., `primary`, `secondary`) that map to color strings. |
735
- | `mode` | `'light' \| 'dark'`| `'light'` | Sets the initial theme mode. |
736
- | `dark` | `Colors` | Default dark palette & main colors | Configuration object for dark mode containing `main` (singleton colors) and `palette`. |
737
- | `light` | `Colors` | Default light palette & main colors | Configuration object for light mode containing `main` (singleton colors) and `palette`.|
778
+ | Prop | Type | Default | Description |
779
+ | :------------- | :------------------ | :---------------------------------- | :-------------------------------------------------------------------------------- |
780
+ | `theme` | `Partial<Theme>` | `{ primary: 'color-black', ... }` | Custom theme tokens (e.g., `primary`, `secondary`) that map to color strings. |
781
+ | `mode` | `'light' \| 'dark'` | `'light'` | Sets the initial theme mode. |
782
+ | `dark` | `Partial<Colors>` | Default dark palette & main colors | Configuration object for dark mode containing `main` (singleton colors) and `palette`. |
783
+ | `light` | `Partial<Colors>` | Default light palette & main colors | Configuration object for light mode containing `main` (singleton colors) and `palette`.|
784
+ | `strict` | `boolean` | `false` | When `true`, logs a console warning whenever a color prop is passed a value that isn't a dash-notation token (`color-*`, `theme-*`, `light-*`, `dark-*`). Useful in dev to catch raw hex/CSS colors leaking into the design system. |
785
+ | `targetWindow` | `Window` | `undefined` | When set, the generated `<style>` tag with CSS variables is injected into the given window's document instead of the current one. Used for iframe support — pass the iframe's `contentWindow` so its `data-theme` selectors see the variables. |
738
786
 
739
787
  **Context Values (via `useTheme`)**
740
788
 
741
- * `getColor(colorName, mode?)`: Resolves a color string (e.g., `color-blue-500`, `theme-primary`, `blackAlpha-500`) to its CSS value for the specified or current theme mode. Most of the time you don't need this — App-Studio components resolve color strings passed as props automatically. Use `getColor` only when you need the raw CSS value (e.g., for non-App-Studio elements or computed styles).
789
+ * `getColor(name, override?)`: Resolves a color token (e.g., `color-blue-500`, `theme-primary`, `color-blue-500-200`) to its CSS value. Returns a `var(--…)` reference for palette/theme tokens, a `color-mix(...)` expression for alpha-suffixed tokens, or the raw value for direct colors (`#hex`, `rgb()`). The optional `override` is `{ theme?, colors?, themeMode? }` — pass it to resolve a token against a one-off theme/palette/mode without mutating the global one. Most of the time you don't need to call this directly — App-Studio components resolve color strings passed as props automatically. Use it for non-App-Studio elements or computed styles.
790
+ * `getColorHex(name, override?)`: Resolves a token down to a concrete `#rrggbb[aa]` hex string. Useful when a third-party library demands a literal color (no `var(--…)`).
791
+ * `getColorRGBA(name, alpha?, override?)`: Same idea as `getColorHex`, but returns `rgba(r, g, b, a)`. The optional `alpha` is on the 0–1000 scale (matches the alpha-suffix syntax).
792
+ * `getColorScheme(name, override?)`: Given a token or a hex literal, returns the closest palette name (`'blue'`, `'rose'`, …) or `undefined`. Useful for picking matching icons/illustrations from a color.
793
+ * `getContrastColor(name, override?)`: Returns `'black'` or `'white'` for the most readable foreground on the given background color, using the WCAG luminance formula.
742
794
  * `theme`: The merged theme configuration object.
743
- * `themeMode`: The current mode ('light' or 'dark').
795
+ * `colors`: The current mode's resolved `{ main, palette }` color objects.
796
+ * `themeMode`: The current mode (`'light'` or `'dark'`).
744
797
  * `setThemeMode(mode)`: Function to change the theme mode.
745
798
 
746
799
  ## ResponsiveProvider
@@ -919,13 +972,14 @@ Explore our comprehensive documentation to learn more about App-Studio:
919
972
  - [Getting Started](docs/README.md) - Quick start guide and core concepts
920
973
  - [Components](docs/Components.md) - Detailed documentation of all available components
921
974
  - [Hooks](docs/Hooks.md) - Guide to the React hooks provided by App-Studio
922
- - [Theming](docs/Theming.md) - Color systems, theme colors, palettes, and light/dark modes
975
+ - [Theming](docs/Theming.md) - Color systems, theme tokens, palettes, light/dark modes, and component-level sub-theming via the `theme` prop
923
976
  - [Styling](docs/Styling.md) - Advanced guide to state modifiers, pseudo-elements, media queries, and CSS system
924
977
  - [Animation](docs/Animation.md) - Creating animations with App-Studio
925
978
  - [Responsive Design](docs/Responsive.md) - Building responsive layouts
926
979
  - [Design System](docs/Design.md) - Understanding the design system
927
980
  - [Event Handling](docs/Events.md) - Working with events and interactions
928
981
  - [Providers](docs/Providers.md) - Context providers for global state
982
+ - [React Native](docs/Native.md) - Using App-Studio in React Native projects: component mapping, native-only props, hook differences, and a web/native cheat sheet
929
983
  - [Migration Guide](codemod/README.md) - Migrating to App-Studio
930
984
 
931
985
  ---
@@ -967,4 +1021,4 @@ Contributions are welcome! Please follow standard procedures:
967
1021
  * Basic components: `View`, `Text`, `Image`, `Form`, `Skeleton`.
968
1022
  * Hooks for interactions, viewport, and responsiveness.
969
1023
  * Providers for Theme, Responsiveness, Analytics, WindowSize.
970
- * Animation system via `Animation` object.
1024
+ * Animation system via `Animation` object.