@xaui/native 0.9.1-alpha.1 → 0.9.1-alpha.10

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.
@@ -1,7 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
- var _chunkM7P46XKIcjs = require('./chunk-M7P46XKI.cjs');
4
+
5
+ var _chunk3QBT3Q65cjs = require('./chunk-3QBT3Q65.cjs');
5
6
 
6
7
  // src/provider/xaui-provider.tsx
7
8
  var _reactnative = require('react-native');
@@ -26,38 +27,38 @@ function stableHash(value) {
26
27
  // src/theme/derive-colors.ts
27
28
  function deriveColors(s) {
28
29
  return {
29
- accentPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.accent, s.accentForeground, 0.1),
30
- successPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.success, s.successForeground, 0.1),
31
- warningPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.warning, s.warningForeground, 0.1),
32
- dangerPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.danger, s.dangerForeground, 0.1),
33
- defaultPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.default, s.defaultForeground, 0.04),
34
- surfacePressed: _chunkM7P46XKIcjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.08),
35
- defaultSoft: _chunkM7P46XKIcjs.alpha.call(void 0, s.default, 0.5),
30
+ accentPressed: _chunk3QBT3Q65cjs.mix.call(void 0, s.accent, s.accentForeground, 0.1),
31
+ successPressed: _chunk3QBT3Q65cjs.mix.call(void 0, s.success, s.successForeground, 0.1),
32
+ warningPressed: _chunk3QBT3Q65cjs.mix.call(void 0, s.warning, s.warningForeground, 0.1),
33
+ dangerPressed: _chunk3QBT3Q65cjs.mix.call(void 0, s.danger, s.dangerForeground, 0.1),
34
+ defaultPressed: _chunk3QBT3Q65cjs.mix.call(void 0, s.default, s.defaultForeground, 0.04),
35
+ surfacePressed: _chunk3QBT3Q65cjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.08),
36
+ defaultSoft: _chunk3QBT3Q65cjs.alpha.call(void 0, s.default, 0.5),
36
37
  defaultSoftForeground: s.defaultForeground,
37
- defaultSoftPressed: _chunkM7P46XKIcjs.alpha.call(void 0, s.default, 0.6),
38
- accentSoft: _chunkM7P46XKIcjs.alpha.call(void 0, s.accent, 0.15),
39
- accentSoftForeground: _chunkM7P46XKIcjs.mix.call(void 0, s.accent, s.foreground, 0.2),
40
- accentSoftPressed: _chunkM7P46XKIcjs.alpha.call(void 0, s.accent, 0.2),
41
- successSoft: _chunkM7P46XKIcjs.alpha.call(void 0, s.success, 0.15),
42
- successSoftForeground: _chunkM7P46XKIcjs.mix.call(void 0, s.success, s.foreground, 0.3),
43
- successSoftPressed: _chunkM7P46XKIcjs.alpha.call(void 0, s.success, 0.2),
44
- warningSoft: _chunkM7P46XKIcjs.alpha.call(void 0, s.warning, 0.15),
45
- warningSoftForeground: _chunkM7P46XKIcjs.mix.call(void 0, s.warning, s.foreground, 0.35),
46
- warningSoftPressed: _chunkM7P46XKIcjs.alpha.call(void 0, s.warning, 0.2),
47
- dangerSoft: _chunkM7P46XKIcjs.alpha.call(void 0, s.danger, 0.15),
48
- dangerSoftForeground: _chunkM7P46XKIcjs.mix.call(void 0, s.danger, s.foreground, 0.2),
49
- dangerSoftPressed: _chunkM7P46XKIcjs.alpha.call(void 0, s.danger, 0.2),
50
- backgroundSecondary: _chunkM7P46XKIcjs.mix.call(void 0, s.background, s.foreground, 0.04),
51
- backgroundTertiary: _chunkM7P46XKIcjs.mix.call(void 0, s.background, s.foreground, 0.08),
38
+ defaultSoftPressed: _chunk3QBT3Q65cjs.alpha.call(void 0, s.default, 0.6),
39
+ accentSoft: _chunk3QBT3Q65cjs.alpha.call(void 0, s.accent, 0.15),
40
+ accentSoftForeground: _chunk3QBT3Q65cjs.mix.call(void 0, s.accent, s.foreground, 0.2),
41
+ accentSoftPressed: _chunk3QBT3Q65cjs.alpha.call(void 0, s.accent, 0.2),
42
+ successSoft: _chunk3QBT3Q65cjs.alpha.call(void 0, s.success, 0.15),
43
+ successSoftForeground: _chunk3QBT3Q65cjs.mix.call(void 0, s.success, s.foreground, 0.3),
44
+ successSoftPressed: _chunk3QBT3Q65cjs.alpha.call(void 0, s.success, 0.2),
45
+ warningSoft: _chunk3QBT3Q65cjs.alpha.call(void 0, s.warning, 0.15),
46
+ warningSoftForeground: _chunk3QBT3Q65cjs.mix.call(void 0, s.warning, s.foreground, 0.35),
47
+ warningSoftPressed: _chunk3QBT3Q65cjs.alpha.call(void 0, s.warning, 0.2),
48
+ dangerSoft: _chunk3QBT3Q65cjs.alpha.call(void 0, s.danger, 0.15),
49
+ dangerSoftForeground: _chunk3QBT3Q65cjs.mix.call(void 0, s.danger, s.foreground, 0.2),
50
+ dangerSoftPressed: _chunk3QBT3Q65cjs.alpha.call(void 0, s.danger, 0.2),
51
+ backgroundSecondary: _chunk3QBT3Q65cjs.mix.call(void 0, s.background, s.foreground, 0.04),
52
+ backgroundTertiary: _chunk3QBT3Q65cjs.mix.call(void 0, s.background, s.foreground, 0.08),
52
53
  backgroundInverse: s.foreground,
53
- borderSecondary: _chunkM7P46XKIcjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.22),
54
- borderTertiary: _chunkM7P46XKIcjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.34),
55
- separatorSecondary: _chunkM7P46XKIcjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.15),
56
- separatorTertiary: _chunkM7P46XKIcjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.19),
57
- fieldPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.fieldBackground, s.fieldForeground, 0.1),
54
+ borderSecondary: _chunk3QBT3Q65cjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.22),
55
+ borderTertiary: _chunk3QBT3Q65cjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.34),
56
+ separatorSecondary: _chunk3QBT3Q65cjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.15),
57
+ separatorTertiary: _chunk3QBT3Q65cjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.19),
58
+ fieldPressed: _chunk3QBT3Q65cjs.mix.call(void 0, s.fieldBackground, s.fieldForeground, 0.1),
58
59
  fieldFocus: s.fieldBackground,
59
- fieldBorderPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.fieldBorder, s.fieldForeground, 0.12),
60
- fieldBorderFocus: _chunkM7P46XKIcjs.mix.call(void 0, s.fieldBorder, s.fieldForeground, 0.26)
60
+ fieldBorderPressed: _chunk3QBT3Q65cjs.mix.call(void 0, s.fieldBorder, s.fieldForeground, 0.12),
61
+ fieldBorderFocus: _chunk3QBT3Q65cjs.mix.call(void 0, s.fieldBorder, s.fieldForeground, 0.26)
61
62
  };
62
63
  }
63
64
 
@@ -385,11 +386,8 @@ function createTheme(config = {}) {
385
386
  }
386
387
  var defaultTheme = createTheme();
387
388
 
388
- // src/theme/theme-context.ts
389
- var _react = require('react');
390
- var ThemeContext = _react.createContext.call(void 0, null);
391
-
392
389
  // src/provider/xaui-provider.tsx
390
+ var _jsxruntime = require('react/jsx-runtime');
393
391
  function XAUIProvider({
394
392
  children,
395
393
  theme = defaultTheme,
@@ -397,7 +395,7 @@ function XAUIProvider({
397
395
  }) {
398
396
  const scheme = _reactnative.useColorScheme.call(void 0, );
399
397
  const resolved = colorMode === "system" ? scheme === "dark" ? "dark" : "light" : colorMode;
400
- return /* @__PURE__ */ React.createElement(ThemeContext.Provider, { value: theme[resolved] }, children);
398
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3QBT3Q65cjs.ThemeContext.Provider, { value: theme[resolved], children });
401
399
  }
402
400
 
403
401
  // src/theme/palette.ts
@@ -699,27 +697,6 @@ var primitives = {
699
697
  eclipse: "#18181b"
700
698
  };
701
699
 
702
- // src/theme/theme-hooks.ts
703
-
704
- function useXAUITheme() {
705
- const theme = _react.useContext.call(void 0, ThemeContext);
706
- if (theme === null) {
707
- throw new Error("XAUI: useXAUITheme must be used within <XAUIProvider>.");
708
- }
709
- return theme;
710
- }
711
- function useColorMode() {
712
- return useXAUITheme().mode;
713
- }
714
- function useThemeColor(token) {
715
- const { colors } = useXAUITheme();
716
- return Array.isArray(token) ? token.map((key) => colors[key]) : colors[token];
717
- }
718
-
719
-
720
-
721
-
722
-
723
700
 
724
701
 
725
702
 
@@ -731,4 +708,4 @@ function useThemeColor(token) {
731
708
 
732
709
 
733
710
 
734
- exports.deriveColors = deriveColors; exports.buildRadius = buildRadius; exports.buildShadows = buildShadows; exports.tokens = tokens; exports.sourceKeys = sourceKeys; exports.createTheme = createTheme; exports.defaultTheme = defaultTheme; exports.ThemeContext = ThemeContext; exports.XAUIProvider = XAUIProvider; exports.palette = palette; exports.primitives = primitives; exports.useXAUITheme = useXAUITheme; exports.useColorMode = useColorMode; exports.useThemeColor = useThemeColor;
711
+ exports.deriveColors = deriveColors; exports.buildRadius = buildRadius; exports.buildShadows = buildShadows; exports.tokens = tokens; exports.sourceKeys = sourceKeys; exports.createTheme = createTheme; exports.defaultTheme = defaultTheme; exports.XAUIProvider = XAUIProvider; exports.palette = palette; exports.primitives = primitives;
@@ -1,4 +1,25 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/colors.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/theme/theme-context.ts
2
+ var _react = require('react');
3
+ var ThemeContext = _react.createContext.call(void 0, null);
4
+
5
+ // src/theme/theme-hooks.ts
6
+
7
+ function useXAUITheme() {
8
+ const theme = _react.useContext.call(void 0, ThemeContext);
9
+ if (theme === null) {
10
+ throw new Error("XAUI: useXAUITheme must be used within <XAUIProvider>.");
11
+ }
12
+ return theme;
13
+ }
14
+ function useColorMode() {
15
+ return useXAUITheme().mode;
16
+ }
17
+ function useThemeColor(token) {
18
+ const { colors } = useXAUITheme();
19
+ return Array.isArray(token) ? token.map((key) => colors[key]) : colors[token];
20
+ }
21
+
22
+ // src/utils/colors.ts
2
23
  var srgbToLinear = (c) => c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
3
24
  var linearToSrgb = (c) => c <= 31308e-7 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055;
4
25
  var clamp01 = (n) => Math.min(1, Math.max(0, n));
@@ -97,4 +118,8 @@ function deriveTint(tint, theme) {
97
118
 
98
119
 
99
120
 
100
- exports.mix = mix; exports.alpha = alpha; exports.deriveTint = deriveTint;
121
+
122
+
123
+
124
+
125
+ exports.ThemeContext = ThemeContext; exports.useXAUITheme = useXAUITheme; exports.useColorMode = useColorMode; exports.useThemeColor = useThemeColor; exports.mix = mix; exports.alpha = alpha; exports.deriveTint = deriveTint;
@@ -0,0 +1,57 @@
1
+ // src/system/portal/portal.tsx
2
+ import { useContext, useId, useLayoutEffect } from "react";
3
+
4
+ // src/system/portal/portal-context.ts
5
+ import { createContext } from "react";
6
+ var PortalContext = createContext(null);
7
+
8
+ // src/system/portal/portal.tsx
9
+ function Portal({ children }) {
10
+ const context = useContext(PortalContext);
11
+ const key = useId();
12
+ useLayoutEffect(() => {
13
+ context?.addPortal(key, children);
14
+ }, [children, context, key]);
15
+ useLayoutEffect(() => {
16
+ return () => context?.removePortal(key);
17
+ }, [context, key]);
18
+ return null;
19
+ }
20
+ Portal.displayName = "XAUI.Portal";
21
+
22
+ // src/system/portal/portal-host.tsx
23
+ import { Fragment, useCallback, useMemo, useState } from "react";
24
+ import { StyleSheet, View } from "react-native";
25
+ import { jsx, jsxs } from "react/jsx-runtime";
26
+ var styles = StyleSheet.create({
27
+ container: { flex: 1 }
28
+ });
29
+ function PortalHost({ children }) {
30
+ const [portals, setPortals] = useState(/* @__PURE__ */ new Map());
31
+ const addPortal = useCallback((key, element) => {
32
+ setPortals((current) => new Map(current).set(key, element));
33
+ }, []);
34
+ const removePortal = useCallback((key) => {
35
+ setPortals((current) => {
36
+ if (!current.has(key)) return current;
37
+ const next = new Map(current);
38
+ next.delete(key);
39
+ return next;
40
+ });
41
+ }, []);
42
+ const methods = useMemo(
43
+ () => ({ addPortal, removePortal }),
44
+ [addPortal, removePortal]
45
+ );
46
+ return /* @__PURE__ */ jsx(PortalContext.Provider, { value: methods, children: /* @__PURE__ */ jsxs(View, { style: styles.container, children: [
47
+ children,
48
+ Array.from(portals, ([key, element]) => /* @__PURE__ */ jsx(Fragment, { children: element }, key))
49
+ ] }) });
50
+ }
51
+ PortalHost.displayName = "XAUI.PortalHost";
52
+
53
+ export {
54
+ PortalContext,
55
+ Portal,
56
+ PortalHost
57
+ };