@xaui/native 0.9.1-alpha.4 → 0.9.1-alpha.40
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.
- package/dist/chunk-2EGR4LWD.js +145 -0
- package/dist/chunk-2NRZKJG7.js +531 -0
- package/dist/chunk-2PMXMKS5.js +67 -0
- package/dist/chunk-2XPG2243.js +586 -0
- package/dist/chunk-36PRYGAM.js +13 -0
- package/dist/chunk-3E7CDKFO.cjs +696 -0
- package/dist/chunk-3GFRSZYR.js +54 -0
- package/dist/chunk-423RQBOX.js +21 -0
- package/dist/chunk-4CUZZWFW.js +92 -0
- package/dist/chunk-4GTAZM2C.js +174 -0
- package/dist/chunk-4KFKWBN5.cjs +89 -0
- package/dist/{chunk-3QBT3Q65.cjs → chunk-57SJ4LJF.cjs} +7 -2
- package/dist/chunk-5R26NM4M.cjs +402 -0
- package/dist/chunk-5VKYNBNA.js +607 -0
- package/dist/chunk-64MXEVT3.js +66 -0
- package/dist/chunk-6DOLGZVV.cjs +147 -0
- package/dist/chunk-6L2TS2R3.cjs +92 -0
- package/dist/chunk-6UEZJRVI.js +669 -0
- package/dist/chunk-734MFAX4.js +27 -0
- package/dist/chunk-73RKQC5X.js +104 -0
- package/dist/chunk-7DPL3ZDS.cjs +21 -0
- package/dist/chunk-7EIHHOHP.cjs +42 -0
- package/dist/chunk-7GHM4GKL.cjs +119 -0
- package/dist/chunk-7YF5NAHQ.cjs +74 -0
- package/dist/{chunk-X2K2FX3W.js → chunk-A3EGFI6T.js} +6 -1
- package/dist/chunk-ABAGZTXZ.cjs +736 -0
- package/dist/{chunk-AW63PTQ4.cjs → chunk-ACAPTWE3.cjs} +85 -81
- package/dist/chunk-AMCSSOJT.cjs +104 -0
- package/dist/chunk-BA2DBSAN.js +102 -0
- package/dist/chunk-BRRXFOBY.js +431 -0
- package/dist/chunk-C5YLPCFC.cjs +293 -0
- package/dist/chunk-DA3OKXHV.cjs +700 -0
- package/dist/chunk-DD4276RF.js +366 -0
- package/dist/chunk-DG2I4PJG.js +701 -0
- package/dist/chunk-DHGLGSH6.js +661 -0
- package/dist/chunk-DIBUQ46Y.js +346 -0
- package/dist/chunk-EGLLDKN6.js +9 -0
- package/dist/chunk-EJQCQPET.cjs +9 -0
- package/dist/chunk-EKS3W46M.cjs +66 -0
- package/dist/chunk-EZEYMLO3.js +402 -0
- package/dist/chunk-F6CQ6CBI.cjs +112 -0
- package/dist/chunk-F6W3JQ7K.js +42 -0
- package/dist/chunk-FHUYHV6J.js +89 -0
- package/dist/chunk-FNEUOBCV.cjs +174 -0
- package/dist/chunk-G7P3ERYF.cjs +478 -0
- package/dist/chunk-GA6PBWNT.js +147 -0
- package/dist/chunk-GFUZ3MUT.cjs +455 -0
- package/dist/chunk-GGW43Q37.cjs +1 -0
- package/dist/chunk-GTR5X65M.cjs +27 -0
- package/dist/chunk-H4E4HDEP.cjs +13 -0
- package/dist/chunk-H7DS4IO7.js +198 -0
- package/dist/chunk-HDVVZG4S.cjs +198 -0
- package/dist/chunk-IKJVLJKT.js +151 -0
- package/dist/chunk-J3MB4PI5.cjs +531 -0
- package/dist/chunk-K72UDPVN.js +119 -0
- package/dist/chunk-KCMYU7WF.js +86 -0
- package/dist/chunk-LRN3RNDO.js +940 -0
- package/dist/chunk-LTX6TB5I.js +124 -0
- package/dist/chunk-LUPCPLND.cjs +145 -0
- package/dist/chunk-M63GFNKV.js +194 -0
- package/dist/chunk-N3KTZMPG.js +293 -0
- package/dist/chunk-NCTOTTVW.js +13 -0
- package/dist/chunk-NWGLP6JX.cjs +410 -0
- package/dist/chunk-R73XQK7X.cjs +314 -0
- package/dist/chunk-RU7JCMWC.cjs +881 -0
- package/dist/chunk-SNIHUKDA.cjs +184 -0
- package/dist/chunk-T5FV5F7A.cjs +607 -0
- package/dist/chunk-TDTUAIFF.cjs +153 -0
- package/dist/chunk-TJ74XVZN.cjs +431 -0
- package/dist/chunk-TK44VBIE.cjs +194 -0
- package/dist/chunk-UAWBAD4E.cjs +346 -0
- package/dist/chunk-UFTCTTKK.js +381 -0
- package/dist/chunk-WDDXU3OH.cjs +67 -0
- package/dist/chunk-WFEMJCXO.cjs +13 -0
- package/dist/chunk-WHJTBTYM.js +0 -0
- package/dist/{chunk-2KXQATVL.js → chunk-WKCQ6VGW.js} +59 -55
- package/dist/chunk-XFPQFCEK.js +455 -0
- package/dist/chunk-XSQPVDFH.cjs +60 -0
- package/dist/chunk-XTC2SLFT.js +153 -0
- package/dist/chunk-XV735BSA.cjs +366 -0
- package/dist/chunk-XWNG2U4K.cjs +124 -0
- package/dist/chunk-YGYYJ3LQ.js +314 -0
- package/dist/chunk-YVHT2UVW.js +74 -0
- package/dist/chunk-ZFOOJK37.cjs +86 -0
- package/dist/close-button.type-BUYuoSt2.d.ts +36 -0
- package/dist/close-button.type-CHsgZ3wO.d.cts +36 -0
- package/dist/components/accordion/index.cjs +35 -0
- package/dist/components/accordion/index.d.cts +299 -0
- package/dist/components/accordion/index.d.ts +299 -0
- package/dist/components/accordion/index.js +35 -0
- package/dist/components/alert/index.cjs +20 -0
- package/dist/components/alert/index.d.cts +169 -0
- package/dist/components/alert/index.d.ts +169 -0
- package/dist/components/alert/index.js +20 -0
- package/dist/components/avatar/index.cjs +16 -0
- package/dist/components/avatar/index.d.cts +131 -0
- package/dist/components/avatar/index.d.ts +131 -0
- package/dist/components/avatar/index.js +16 -0
- package/dist/components/badge/index.cjs +15 -0
- package/dist/components/badge/index.d.cts +157 -0
- package/dist/components/badge/index.d.ts +157 -0
- package/dist/components/badge/index.js +15 -0
- package/dist/components/button/index.cjs +22 -0
- package/dist/components/button/index.d.cts +613 -0
- package/dist/components/button/index.d.ts +613 -0
- package/dist/components/button/index.js +22 -0
- package/dist/components/card/index.cjs +22 -0
- package/dist/components/card/index.d.cts +620 -0
- package/dist/components/card/index.d.ts +620 -0
- package/dist/components/card/index.js +22 -0
- package/dist/components/checkbox/index.cjs +26 -0
- package/dist/components/checkbox/index.d.cts +1136 -0
- package/dist/components/checkbox/index.d.ts +1136 -0
- package/dist/components/checkbox/index.js +26 -0
- package/dist/components/chip/index.cjs +20 -0
- package/dist/components/chip/index.d.cts +608 -0
- package/dist/components/chip/index.d.ts +608 -0
- package/dist/components/chip/index.js +20 -0
- package/dist/components/divider/index.cjs +13 -0
- package/dist/components/divider/index.d.cts +117 -0
- package/dist/components/divider/index.d.ts +117 -0
- package/dist/components/divider/index.js +13 -0
- package/dist/components/field-group/index.cjs +27 -0
- package/dist/components/field-group/index.d.cts +270 -0
- package/dist/components/field-group/index.d.ts +270 -0
- package/dist/components/field-group/index.js +27 -0
- package/dist/components/input-otp/index.cjs +29 -0
- package/dist/components/input-otp/index.d.cts +325 -0
- package/dist/components/input-otp/index.d.ts +325 -0
- package/dist/components/input-otp/index.js +29 -0
- package/dist/components/menu/index.cjs +49 -0
- package/dist/components/menu/index.d.cts +351 -0
- package/dist/components/menu/index.d.ts +351 -0
- package/dist/components/menu/index.js +49 -0
- package/dist/components/popover/index.cjs +38 -0
- package/dist/components/popover/index.d.cts +254 -0
- package/dist/components/popover/index.d.ts +254 -0
- package/dist/components/popover/index.js +38 -0
- package/dist/components/radio/index.cjs +26 -0
- package/dist/components/radio/index.d.cts +1102 -0
- package/dist/components/radio/index.d.ts +1102 -0
- package/dist/components/radio/index.js +26 -0
- package/dist/components/select/index.cjs +50 -0
- package/dist/components/select/index.d.cts +498 -0
- package/dist/components/select/index.d.ts +498 -0
- package/dist/components/select/index.js +50 -0
- package/dist/components/skeleton/index.cjs +11 -0
- package/dist/components/skeleton/index.d.cts +111 -0
- package/dist/components/skeleton/index.d.ts +111 -0
- package/dist/components/skeleton/index.js +11 -0
- package/dist/components/spinner/index.cjs +17 -0
- package/dist/components/spinner/index.d.cts +104 -0
- package/dist/components/spinner/index.d.ts +104 -0
- package/dist/components/spinner/index.js +17 -0
- package/dist/components/switch/index.cjs +27 -0
- package/dist/components/switch/index.d.cts +1154 -0
- package/dist/components/switch/index.d.ts +1154 -0
- package/dist/components/switch/index.js +27 -0
- package/dist/components/text-area/index.cjs +14 -0
- package/dist/components/text-area/index.d.cts +73 -0
- package/dist/components/text-area/index.d.ts +73 -0
- package/dist/components/text-area/index.js +14 -0
- package/dist/components/text-field/index.cjs +25 -0
- package/dist/components/text-field/index.d.cts +205 -0
- package/dist/components/text-field/index.d.ts +205 -0
- package/dist/components/text-field/index.js +25 -0
- package/dist/components/typography/index.cjs +15 -0
- package/dist/components/typography/index.d.cts +116 -0
- package/dist/components/typography/index.d.ts +116 -0
- package/dist/components/typography/index.js +15 -0
- package/dist/components/view/index.cjs +17 -0
- package/dist/components/view/index.d.cts +152 -0
- package/dist/components/view/index.d.ts +152 -0
- package/dist/components/view/index.js +17 -0
- package/dist/create-recipe-BdVd2ffi.d.ts +114 -0
- package/dist/create-recipe-dC7wMfnj.d.cts +114 -0
- package/dist/icon.type-Kml72iSz.d.ts +73 -0
- package/dist/icon.type-d_i9ma-i.d.cts +73 -0
- package/dist/index.cjs +400 -4
- package/dist/index.d.cts +118 -4
- package/dist/index.d.ts +118 -4
- package/dist/index.js +423 -27
- package/dist/placement-DHa0Rrh1.d.cts +38 -0
- package/dist/placement-DHa0Rrh1.d.ts +38 -0
- package/dist/pressable-feedback.type-BA2C9sSz.d.cts +127 -0
- package/dist/pressable-feedback.type-Bs4dQlGj.d.ts +127 -0
- package/dist/style-props.type-CfnoGEP7.d.cts +31 -0
- package/dist/style-props.type-CfnoGEP7.d.ts +31 -0
- package/dist/system/index.cjs +73 -4
- package/dist/system/index.d.cts +379 -193
- package/dist/system/index.d.ts +379 -193
- package/dist/system/index.js +87 -18
- package/dist/text-field.type-0l73acce.d.ts +167 -0
- package/dist/text-field.type-DBh06DU5.d.cts +167 -0
- package/dist/theme/index.cjs +5 -3
- package/dist/theme/index.d.cts +55 -24
- package/dist/theme/index.d.ts +55 -24
- package/dist/theme/index.js +4 -2
- package/dist/{theme.type-C9bFJKFm.d.cts → theme.type-C2gNHpEx.d.cts} +1 -1
- package/dist/{theme.type-C9bFJKFm.d.ts → theme.type-C2gNHpEx.d.ts} +1 -1
- package/package.json +254 -18
- package/dist/chunk-ECDWSSHJ.js +0 -688
- package/dist/chunk-IYFGO523.cjs +0 -688
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createRecipe
|
|
3
|
+
} from "./chunk-4GTAZM2C.js";
|
|
4
|
+
import {
|
|
5
|
+
useXAUITheme
|
|
6
|
+
} from "./chunk-A3EGFI6T.js";
|
|
7
|
+
import {
|
|
8
|
+
Slot
|
|
9
|
+
} from "./chunk-K72UDPVN.js";
|
|
10
|
+
import {
|
|
11
|
+
useStyleProps
|
|
12
|
+
} from "./chunk-M63GFNKV.js";
|
|
13
|
+
|
|
14
|
+
// src/components/typography/typography.tsx
|
|
15
|
+
import { forwardRef } from "react";
|
|
16
|
+
import { Text } from "react-native";
|
|
17
|
+
|
|
18
|
+
// src/components/typography/typography.recipe.ts
|
|
19
|
+
var SLOTS = ["root"];
|
|
20
|
+
var VARIANT_TOKENS = {
|
|
21
|
+
h1: { fg: "foreground" },
|
|
22
|
+
h2: { fg: "foreground" },
|
|
23
|
+
h3: { fg: "foreground" },
|
|
24
|
+
h4: { fg: "foreground" },
|
|
25
|
+
h5: { fg: "foreground" },
|
|
26
|
+
h6: { fg: "foreground" },
|
|
27
|
+
body: { fg: "foreground" },
|
|
28
|
+
"body-sm": { fg: "foreground" },
|
|
29
|
+
"body-xs": { fg: "foreground" },
|
|
30
|
+
code: { fg: "foreground" }
|
|
31
|
+
};
|
|
32
|
+
var ROLES = {
|
|
33
|
+
h1: { step: "4xl", weight: "bold", family: "heading", letterSpacing: -0.5 },
|
|
34
|
+
h2: { step: "3xl", weight: "bold", family: "heading", letterSpacing: -0.4 },
|
|
35
|
+
h3: { step: "2xl", weight: "bold", family: "heading", letterSpacing: -0.3 },
|
|
36
|
+
h4: { step: "xl", weight: "semibold", family: "heading" },
|
|
37
|
+
h5: { step: "lg", weight: "semibold", family: "heading" },
|
|
38
|
+
h6: { step: "md", weight: "semibold", family: "heading" },
|
|
39
|
+
body: { step: "md", weight: "regular", family: "body" },
|
|
40
|
+
"body-sm": { step: "sm", weight: "regular", family: "body" },
|
|
41
|
+
"body-xs": { step: "xs", weight: "regular", family: "body" },
|
|
42
|
+
code: { step: "sm", weight: "regular", family: "mono", chip: true }
|
|
43
|
+
};
|
|
44
|
+
function metricsOf({ step, weight, family, letterSpacing, chip }) {
|
|
45
|
+
return (theme) => ({
|
|
46
|
+
root: {
|
|
47
|
+
fontSize: theme.fontSizes[step],
|
|
48
|
+
lineHeight: theme.lineHeights[step],
|
|
49
|
+
fontWeight: theme.fontWeights[weight],
|
|
50
|
+
fontFamily: theme.fontFamilies[family],
|
|
51
|
+
...letterSpacing === void 0 ? {} : { letterSpacing },
|
|
52
|
+
...chip === void 0 ? {} : {
|
|
53
|
+
alignSelf: "flex-start",
|
|
54
|
+
backgroundColor: theme.colors.default,
|
|
55
|
+
paddingHorizontal: theme.spacing(1.5),
|
|
56
|
+
paddingVertical: theme.spacing(0.5),
|
|
57
|
+
borderRadius: theme.radius.md
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
var ROLE_AXIS = Object.fromEntries(
|
|
63
|
+
Object.entries(ROLES).map(([name, spec]) => [name, metricsOf(spec)])
|
|
64
|
+
);
|
|
65
|
+
var typographyRecipe = createRecipe({
|
|
66
|
+
slots: SLOTS,
|
|
67
|
+
variantTokens: VARIANT_TOKENS,
|
|
68
|
+
// Ink only. The chip's fill is a token, not a role, so it belongs to the metrics above —
|
|
69
|
+
// where it also stays inside the cache key instead of being recomputed with the tint.
|
|
70
|
+
paint: (_theme, colors) => ({ root: { color: colors.fg } }),
|
|
71
|
+
variants: { variant: ROLE_AXIS },
|
|
72
|
+
defaultVariants: { variant: "body" }
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// src/components/typography/typography.tsx
|
|
76
|
+
import { jsx } from "react/jsx-runtime";
|
|
77
|
+
var Typography = forwardRef(function Typography2({ children, variant, color, asChild = false, style, ...props }, ref) {
|
|
78
|
+
const theme = useXAUITheme();
|
|
79
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
80
|
+
const selection = { variant };
|
|
81
|
+
const styles = typographyRecipe.resolve({ theme, selection });
|
|
82
|
+
const tint = color ? typographyRecipe.tint({ theme, color, selection }) : void 0;
|
|
83
|
+
const rootStyle = [styles.root, tint?.root, styleProps, style];
|
|
84
|
+
const Root = asChild ? Slot : Text;
|
|
85
|
+
return /* @__PURE__ */ jsx(Root, { ref, style: rootStyle, ...rest, children });
|
|
86
|
+
});
|
|
87
|
+
Typography.displayName = "XAUI.Typography";
|
|
88
|
+
|
|
89
|
+
// src/components/typography/text-span.tsx
|
|
90
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
91
|
+
import { Text as Text2 } from "react-native";
|
|
92
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
93
|
+
var TextSpan = forwardRef2(function TextSpan2({ children, asChild = false, style, ...props }, ref) {
|
|
94
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
95
|
+
const Root = asChild ? Slot : Text2;
|
|
96
|
+
return /* @__PURE__ */ jsx2(Root, { ref, style: [styleProps, style], ...rest, children });
|
|
97
|
+
});
|
|
98
|
+
TextSpan.displayName = "XAUI.TextSpan";
|
|
99
|
+
|
|
100
|
+
export {
|
|
101
|
+
typographyRecipe,
|
|
102
|
+
Typography,
|
|
103
|
+
TextSpan
|
|
104
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }// src/hooks/use-press-state.ts
|
|
2
|
+
var _react = require('react');
|
|
3
|
+
function usePressState(handlers = {}) {
|
|
4
|
+
const [isPressed, setIsPressed] = _react.useState.call(void 0, false);
|
|
5
|
+
const latest = _react.useRef.call(void 0, handlers);
|
|
6
|
+
latest.current = handlers;
|
|
7
|
+
const onPressIn = _react.useCallback.call(void 0, (event) => {
|
|
8
|
+
setIsPressed(true);
|
|
9
|
+
_optionalChain([latest, 'access', _ => _.current, 'access', _2 => _2.onPressIn, 'optionalCall', _3 => _3(event)]);
|
|
10
|
+
}, []);
|
|
11
|
+
const onPressOut = _react.useCallback.call(void 0, (event) => {
|
|
12
|
+
setIsPressed(false);
|
|
13
|
+
_optionalChain([latest, 'access', _4 => _4.current, 'access', _5 => _5.onPressOut, 'optionalCall', _6 => _6(event)]);
|
|
14
|
+
}, []);
|
|
15
|
+
const press = _react.useRef.call(void 0, { onPressIn, onPressOut }).current;
|
|
16
|
+
return [isPressed, press];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
exports.usePressState = usePressState;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
|
+
|
|
3
|
+
var _chunkEJQCQPETcjs = require('./chunk-EJQCQPET.cjs');
|
|
4
|
+
|
|
5
|
+
// src/hooks/use-controllable-state.ts
|
|
6
|
+
var _react = require('react');
|
|
7
|
+
function useControllableState({
|
|
8
|
+
value,
|
|
9
|
+
defaultValue,
|
|
10
|
+
onChange
|
|
11
|
+
}) {
|
|
12
|
+
const [uncontrolled, setUncontrolled] = _react.useState.call(void 0, defaultValue);
|
|
13
|
+
const isControlled = value !== void 0;
|
|
14
|
+
const current = isControlled ? value : uncontrolled;
|
|
15
|
+
useControlWarning(isControlled);
|
|
16
|
+
const latest = _react.useRef.call(void 0, current);
|
|
17
|
+
latest.current = current;
|
|
18
|
+
const onChangeRef = _react.useRef.call(void 0, onChange);
|
|
19
|
+
onChangeRef.current = onChange;
|
|
20
|
+
const controlled = _react.useRef.call(void 0, isControlled);
|
|
21
|
+
controlled.current = isControlled;
|
|
22
|
+
const set = _react.useCallback.call(void 0, (next) => {
|
|
23
|
+
const resolved = typeof next === "function" ? next(latest.current) : next;
|
|
24
|
+
if (resolved === latest.current) return;
|
|
25
|
+
if (!controlled.current) setUncontrolled(resolved);
|
|
26
|
+
_optionalChain([onChangeRef, 'access', _ => _.current, 'optionalCall', _2 => _2(resolved)]);
|
|
27
|
+
}, []);
|
|
28
|
+
return [current, set];
|
|
29
|
+
}
|
|
30
|
+
function useControlWarning(isControlled) {
|
|
31
|
+
const wasControlled = _react.useRef.call(void 0, isControlled);
|
|
32
|
+
if (wasControlled.current !== isControlled) {
|
|
33
|
+
_chunkEJQCQPETcjs.warnDev.call(void 0,
|
|
34
|
+
`a component switched from ${wasControlled.current ? "controlled" : "uncontrolled"} to ${isControlled ? "controlled" : "uncontrolled"}. Decide for the life of the component: pass \`value\` always, or never. Passing \`undefined\` for a value you do control reads as "uncontrolled" here.`
|
|
35
|
+
);
|
|
36
|
+
wasControlled.current = isControlled;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
exports.useControllableState = useControllableState;
|
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
|
|
3
|
+
var _chunkH4E4HDEPcjs = require('./chunk-H4E4HDEP.cjs');
|
|
4
|
+
|
|
5
|
+
// src/system/slot/children-to-string.ts
|
|
6
|
+
var _react = require('react');
|
|
7
|
+
function childrenToString(children) {
|
|
8
|
+
const text = stringify(children);
|
|
9
|
+
return text === null || text === "" ? null : text;
|
|
10
|
+
}
|
|
11
|
+
function stringify(node) {
|
|
12
|
+
if (node === null || node === void 0 || typeof node === "boolean") return "";
|
|
13
|
+
if (typeof node === "string") return node;
|
|
14
|
+
if (typeof node === "number") return String(node);
|
|
15
|
+
if (_react.isValidElement.call(void 0, node)) return null;
|
|
16
|
+
if (Array.isArray(node)) {
|
|
17
|
+
let text = "";
|
|
18
|
+
for (const child of node) {
|
|
19
|
+
const part = stringify(child);
|
|
20
|
+
if (part === null) return null;
|
|
21
|
+
text += part;
|
|
22
|
+
}
|
|
23
|
+
return text;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/system/slot/create-slot-context.ts
|
|
29
|
+
|
|
30
|
+
function createSlotContext(name) {
|
|
31
|
+
const Context = _react.createContext.call(void 0, null);
|
|
32
|
+
Context.displayName = `XAUI.${name}.Context`;
|
|
33
|
+
function useSlotContext() {
|
|
34
|
+
const value = _react.useContext.call(void 0, Context);
|
|
35
|
+
if (value === null) {
|
|
36
|
+
const error = new Error(
|
|
37
|
+
`XAUI: use${name} must be called inside <${name}>. A slot reads the values its root resolved, so it can only be rendered as a child of one.`
|
|
38
|
+
);
|
|
39
|
+
_optionalChain([Error, 'access', _ => _.captureStackTrace, 'optionalCall', _2 => _2(
|
|
40
|
+
error,
|
|
41
|
+
useSlotContext
|
|
42
|
+
)]);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
return [Context.Provider, useSlotContext];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/system/slot/merge-props.ts
|
|
51
|
+
var EVENT_HANDLER = /^on[A-Z]/;
|
|
52
|
+
function mergeProps(ours, theirs) {
|
|
53
|
+
const merged = { ...ours };
|
|
54
|
+
for (const key of Object.keys(theirs)) {
|
|
55
|
+
const ourValue = ours[key];
|
|
56
|
+
const theirValue = theirs[key];
|
|
57
|
+
if (EVENT_HANDLER.test(key)) {
|
|
58
|
+
merged[key] = composeHandlers(ourValue, theirValue);
|
|
59
|
+
} else if (key === "style") {
|
|
60
|
+
merged[key] = mergeStyles(ourValue, theirValue);
|
|
61
|
+
} else if (key === "ref") {
|
|
62
|
+
merged[key] = _chunkH4E4HDEPcjs.mergeRefs.call(void 0,
|
|
63
|
+
ourValue,
|
|
64
|
+
theirValue
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
merged[key] = theirValue;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return merged;
|
|
71
|
+
}
|
|
72
|
+
function composeHandlers(ours, theirs) {
|
|
73
|
+
if (typeof ours !== "function") return theirs;
|
|
74
|
+
if (typeof theirs !== "function") return ours;
|
|
75
|
+
return (...args) => {
|
|
76
|
+
;
|
|
77
|
+
ours(...args);
|
|
78
|
+
return theirs(...args);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function mergeStyles(ours, theirs) {
|
|
82
|
+
if (typeof ours === "function" || typeof theirs === "function") {
|
|
83
|
+
return (state) => [
|
|
84
|
+
resolveStyle(ours, state),
|
|
85
|
+
resolveStyle(theirs, state)
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
return [ours, theirs];
|
|
89
|
+
}
|
|
90
|
+
function resolveStyle(style, state) {
|
|
91
|
+
return typeof style === "function" ? style(state) : style;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/system/slot/slot.tsx
|
|
95
|
+
|
|
96
|
+
var Slot = _react.forwardRef.call(void 0, function Slot2({ children, ...ours }, ref) {
|
|
97
|
+
if (!_react.isValidElement.call(void 0, children)) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
"XAUI: asChild expects exactly one React element as its child, and merges the component's props into it. Text, a fragment, several children or none give it nothing to merge into \u2014 drop `asChild` to render the component itself."
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
const child = children;
|
|
103
|
+
const merged = mergeProps(ours, child.props);
|
|
104
|
+
merged.ref = _chunkH4E4HDEPcjs.mergeRefs.call(void 0, ref, refOf(child));
|
|
105
|
+
return _react.cloneElement.call(void 0, child, merged);
|
|
106
|
+
});
|
|
107
|
+
Slot.displayName = "XAUI.Slot";
|
|
108
|
+
function refOf(element) {
|
|
109
|
+
const fromProps = element.props.ref;
|
|
110
|
+
const fromElement = element.ref;
|
|
111
|
+
return _nullishCoalesce(fromProps, () => ( fromElement));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
exports.childrenToString = childrenToString; exports.createSlotContext = createSlotContext; exports.mergeProps = mergeProps; exports.Slot = Slot;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkJ3MB4PI5cjs = require('./chunk-J3MB4PI5.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunk7GHM4GKLcjs = require('./chunk-7GHM4GKL.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunkTK44VBIEcjs = require('./chunk-TK44VBIE.cjs');
|
|
15
|
+
|
|
16
|
+
// src/components/text-area/text-area-field.tsx
|
|
17
|
+
var _react = require('react');
|
|
18
|
+
|
|
19
|
+
// src/components/text-area/text-area.context.ts
|
|
20
|
+
var [TextAreaProvider, useTextArea] = _chunk7GHM4GKLcjs.createSlotContext.call(void 0, "TextArea");
|
|
21
|
+
|
|
22
|
+
// src/components/text-area/text-area-field.tsx
|
|
23
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
24
|
+
var TextAreaField = _react.forwardRef.call(void 0,
|
|
25
|
+
function TextAreaField2({ style, scrollEnabled, ...props }, ref) {
|
|
26
|
+
const { textAreaStyle, textArea } = _chunkJ3MB4PI5cjs.useTextField.call(void 0, );
|
|
27
|
+
const { rows, maxRows } = useTextArea();
|
|
28
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
29
|
+
const height = _react.useMemo.call(void 0, () => {
|
|
30
|
+
const chrome = textArea.paddingVertical * 2;
|
|
31
|
+
return {
|
|
32
|
+
minHeight: rows * textArea.lineHeight + chrome,
|
|
33
|
+
// Unset, the field grows for as long as the text does. With a ceiling it stops
|
|
34
|
+
// there and scrolls, which is the only case that needs `scrollEnabled` — a
|
|
35
|
+
// multiline field that can grow has nothing to scroll.
|
|
36
|
+
maxHeight: maxRows ? maxRows * textArea.lineHeight + chrome : void 0
|
|
37
|
+
};
|
|
38
|
+
}, [rows, maxRows, textArea]);
|
|
39
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
40
|
+
_chunkJ3MB4PI5cjs.TextFieldField,
|
|
41
|
+
{
|
|
42
|
+
ref,
|
|
43
|
+
multiline: true,
|
|
44
|
+
scrollEnabled: _nullishCoalesce(scrollEnabled, () => ( maxRows !== void 0)),
|
|
45
|
+
...rest,
|
|
46
|
+
style: [textAreaStyle, height, styleProps, style]
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
TextAreaField.displayName = "XAUI.TextArea.Field";
|
|
52
|
+
|
|
53
|
+
// src/components/text-area/text-area.tsx
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
var DEFAULT_ROWS = 3;
|
|
57
|
+
var TextAreaRoot = _react.forwardRef.call(void 0, function TextArea({ rows = DEFAULT_ROWS, maxRows, children, ...props }, ref) {
|
|
58
|
+
const context = _react.useMemo.call(void 0, () => ({ rows, maxRows }), [rows, maxRows]);
|
|
59
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TextAreaProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkJ3MB4PI5cjs.TextFieldRoot, { ref, ...props, children }) });
|
|
60
|
+
});
|
|
61
|
+
TextAreaRoot.displayName = "XAUI.TextArea.Root";
|
|
62
|
+
|
|
63
|
+
// src/components/text-area/index.ts
|
|
64
|
+
var TextArea2 = Object.assign(TextAreaRoot, {
|
|
65
|
+
Label: _chunkJ3MB4PI5cjs.TextFieldLabel,
|
|
66
|
+
Field: TextAreaField,
|
|
67
|
+
Description: _chunkJ3MB4PI5cjs.TextFieldDescription,
|
|
68
|
+
Error: _chunkJ3MB4PI5cjs.TextFieldError
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
exports.useTextArea = useTextArea; exports.TextArea = TextArea2;
|
|
@@ -107,7 +107,10 @@ function deriveTint(tint, theme) {
|
|
|
107
107
|
foreground,
|
|
108
108
|
soft: alpha(tint, 0.15),
|
|
109
109
|
softForeground: mix(tint, theme.colors.foreground, 0.2),
|
|
110
|
-
|
|
110
|
+
// Towards the mode's ink, not the tint's own foreground — the same single direction
|
|
111
|
+
// the token layer takes (P2-API-REVIEW §E). A raw tint has to behave like `accent`
|
|
112
|
+
// under the finger as much as it does at rest.
|
|
113
|
+
pressed: mix(tint, theme.colors.foreground, 0.1),
|
|
111
114
|
softPressed: alpha(tint, 0.2)
|
|
112
115
|
};
|
|
113
116
|
cache.set(key, derived);
|
|
@@ -119,7 +122,9 @@ export {
|
|
|
119
122
|
useXAUITheme,
|
|
120
123
|
useColorMode,
|
|
121
124
|
useThemeColor,
|
|
125
|
+
isHex,
|
|
122
126
|
mix,
|
|
123
127
|
alpha,
|
|
128
|
+
contrastOn,
|
|
124
129
|
deriveTint
|
|
125
130
|
};
|