@duro-app/ui 0.34.6 → 0.34.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.
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ export type ThemeName = 'dark' | 'light' | 'high-contrast';
3
+ interface ThemeProviderProps {
4
+ theme?: ThemeName;
5
+ children: ReactNode;
6
+ }
7
+ export declare function usePortalMount(): HTMLElement | null;
8
+ export declare function ThemeProvider({ theme, children }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=ThemeProvider.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeProvider.native.d.ts","sourceRoot":"","sources":["../../../src/components/ThemeProvider/ThemeProvider.native.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAgB,KAAK,SAAS,EAAa,MAAM,OAAO,CAAA;AAM/D,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,eAAe,CAAA;AAE1D,UAAU,kBAAkB;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAwBD,wBAAgB,cAAc,IAAI,WAAW,GAAG,IAAI,CAEnD;AAED,wBAAgB,aAAa,CAAC,EAAC,KAAc,EAAE,QAAQ,EAAC,EAAE,kBAAkB,2CAI3E"}
@@ -28,4 +28,5 @@ export { Stack, type SpacingKey } from './components/Stack/Stack';
28
28
  export { Inline } from './components/Inline/Inline';
29
29
  export { Cluster } from './components/Cluster/Cluster';
30
30
  export { Grid } from './components/Grid/Grid';
31
+ export { ThemeProvider, usePortalMount, type ThemeName, } from './components/ThemeProvider/ThemeProvider';
31
32
  //# sourceMappingURL=index.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../src/index.native.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAC,KAA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AAA;AACtF,OAAO,EAAC,IAAI,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC5E,OAAO,EAAC,QAAQ,EAAC,MAAM,gCAAgC,CAAA;AACvD,OAAO,EAAC,OAAO,EAAE,KAAK,cAAc,EAAC,MAAM,8BAA8B,CAAA;AACzE,OAAO,EAAC,KAAK,EAAE,KAAK,YAAY,EAAC,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAC,MAAM,EAAC,MAAM,4BAA4B,CAAA;AACjD,OAAO,EAAC,IAAI,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAAC,QAAQ,EAAE,KAAK,eAAe,EAAC,MAAM,gCAAgC,CAAA;AAG7E,OAAO,EAAC,KAAK,EAAC,MAAM,0BAA0B,CAAA;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,oCAAoC,CAAA;AAG7D,OAAO,EAAC,KAAK,EAAE,KAAK,UAAU,EAAC,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAC,MAAM,EAAC,MAAM,4BAA4B,CAAA;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,8BAA8B,CAAA;AACpD,OAAO,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAA;AAI3C,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,SAAS,GACf,MAAM,0CAA0C,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duro-app/ui",
3
- "version": "0.34.6",
3
+ "version": "0.34.7",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -54,7 +54,7 @@
54
54
  }
55
55
  },
56
56
  "dependencies": {
57
- "@duro-app/tokens": "^0.34.6"
57
+ "@duro-app/tokens": "^0.34.7"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@babel/preset-typescript": "^7.28.0",
@@ -0,0 +1,49 @@
1
+ // Native (React Native / Expo) ThemeProvider — Metro resolves this over
2
+ // ThemeProvider.tsx via the platform extension. The web version uses
3
+ // `display:contents` + a fixed portal-mount, neither of which exists on RN, so
4
+ // this applies the theme StyleX styles to a plain flex-column container and
5
+ // drops the portal mount (native overlays don't portal to a fixed div).
6
+ import {createContext, type ReactNode, useContext} from 'react'
7
+ import {css, html} from 'react-strict-dom'
8
+ import {colors} from '@duro-app/tokens/tokens/colors.css'
9
+ import {lightTheme, lightShadows} from '@duro-app/tokens/themes/light.css'
10
+ import {highContrastTheme, highContrastShadows} from '@duro-app/tokens/themes/high-contrast.css'
11
+
12
+ export type ThemeName = 'dark' | 'light' | 'high-contrast'
13
+
14
+ interface ThemeProviderProps {
15
+ theme?: ThemeName
16
+ children: ReactNode
17
+ }
18
+
19
+ const themeMap: Partial<Record<ThemeName, readonly [typeof lightTheme, typeof lightShadows]>> = {
20
+ light: [lightTheme, lightShadows],
21
+ 'high-contrast': [highContrastTheme, highContrastShadows],
22
+ }
23
+
24
+ const styles = css.create({
25
+ // No `display:contents` on RN. RSD uses web flex semantics on native, so
26
+ // declare flex + column explicitly; flex:1 lets a root provider fill.
27
+ root: {
28
+ display: 'flex',
29
+ flexDirection: 'column',
30
+ flex: 1,
31
+ color: colors.text,
32
+ },
33
+ })
34
+
35
+ type DivStyle = Parameters<typeof html.div>[0]['style']
36
+
37
+ // Parity with the web export — there's no portal mount on native, so this is
38
+ // always null. (The components that consume it aren't in the native barrel.)
39
+ const PortalMountContext = createContext<HTMLElement | null>(null)
40
+
41
+ export function usePortalMount(): HTMLElement | null {
42
+ return useContext(PortalMountContext)
43
+ }
44
+
45
+ export function ThemeProvider({theme = 'dark', children}: ThemeProviderProps) {
46
+ const overrides = themeMap[theme]
47
+ const themeStyles = [overrides?.[0], overrides?.[1], styles.root] as DivStyle
48
+ return <html.div style={themeStyles}>{children}</html.div>
49
+ }
@@ -34,3 +34,11 @@ export {Stack, type SpacingKey} from './components/Stack/Stack'
34
34
  export {Inline} from './components/Inline/Inline'
35
35
  export {Cluster} from './components/Cluster/Cluster'
36
36
  export {Grid} from './components/Grid/Grid'
37
+
38
+ // Theming — resolves to ThemeProvider.native.tsx on Metro (RN-safe variant:
39
+ // no display:contents / portal mount; applies the theme to a flex container).
40
+ export {
41
+ ThemeProvider,
42
+ usePortalMount,
43
+ type ThemeName,
44
+ } from './components/ThemeProvider/ThemeProvider'