@xaui/native 0.9.1-alpha.3 → 0.9.1-alpha.31
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-3FV4COTM.js +68 -0
- package/dist/chunk-423RQBOX.js +21 -0
- package/dist/chunk-42FMGB5M.js +661 -0
- package/dist/chunk-4GTAZM2C.js +174 -0
- package/dist/chunk-4XPLPQLM.cjs +147 -0
- package/dist/{chunk-3QBT3Q65.cjs → chunk-57SJ4LJF.cjs} +7 -2
- package/dist/chunk-5GO7MAVY.cjs +74 -0
- package/dist/chunk-5PTBRJM7.cjs +346 -0
- package/dist/chunk-5RQ7AZPN.cjs +455 -0
- package/dist/chunk-5Z4P6WHR.cjs +525 -0
- package/dist/chunk-7DPL3ZDS.cjs +21 -0
- package/dist/chunk-7EIHHOHP.cjs +42 -0
- package/dist/chunk-7SEZGVTY.js +62 -0
- package/dist/chunk-7XKQJQF2.cjs +70 -0
- package/dist/{chunk-X2K2FX3W.js → chunk-A3EGFI6T.js} +6 -1
- package/dist/chunk-A5OCK3C2.js +525 -0
- package/dist/chunk-AETWQQWU.cjs +92 -0
- package/dist/chunk-ANNUYP55.cjs +431 -0
- package/dist/chunk-BA2DBSAN.js +102 -0
- package/dist/chunk-BFMTUMTU.js +669 -0
- package/dist/chunk-BVJQ3UPZ.js +62 -0
- package/dist/chunk-DFME724B.js +147 -0
- package/dist/chunk-E2CWBQTV.js +119 -0
- package/dist/chunk-EGLLDKN6.js +9 -0
- package/dist/chunk-EJQCQPET.cjs +9 -0
- package/dist/chunk-F6CQ6CBI.cjs +112 -0
- package/dist/chunk-F6W3JQ7K.js +42 -0
- package/dist/chunk-FNEUOBCV.cjs +174 -0
- package/dist/chunk-G7K652GC.js +145 -0
- package/dist/chunk-GGW42MY4.js +20 -0
- package/dist/chunk-GLGU2WFL.cjs +190 -0
- package/dist/chunk-GPVNCJ3Z.cjs +696 -0
- package/dist/chunk-GVQOD3VW.js +74 -0
- package/dist/chunk-IHOCANCQ.js +293 -0
- package/dist/chunk-JDFV4W6N.cjs +700 -0
- package/dist/chunk-KOC3KQIT.js +124 -0
- package/dist/chunk-KPWZLUES.cjs +124 -0
- package/dist/chunk-L7JN6OBQ.cjs +314 -0
- package/dist/chunk-MC7SY2QH.cjs +20 -0
- package/dist/chunk-MDVSCWJI.js +314 -0
- package/dist/chunk-N527BTY4.cjs +366 -0
- package/dist/chunk-NYRXUGVL.js +104 -0
- package/dist/{chunk-AW63PTQ4.cjs → chunk-OHEHPQLC.cjs} +72 -72
- package/dist/chunk-Q3WFY5N3.js +366 -0
- package/dist/chunk-QGN2BBJO.cjs +104 -0
- package/dist/chunk-RDTKAAHX.js +346 -0
- package/dist/chunk-TGZZ3RZU.cjs +86 -0
- package/dist/{chunk-2KXQATVL.js → chunk-TZG3DERP.js} +46 -46
- package/dist/chunk-URSKA2VR.js +190 -0
- package/dist/chunk-V4WDMM6Z.js +86 -0
- package/dist/chunk-VJEER76X.js +455 -0
- package/dist/chunk-VZBWYWEI.cjs +736 -0
- package/dist/chunk-WR7YLDVV.cjs +68 -0
- package/dist/chunk-X4HQ4H2V.js +701 -0
- package/dist/chunk-XFSW3ZNI.cjs +145 -0
- package/dist/chunk-XQFAUDR2.cjs +62 -0
- package/dist/chunk-ZH5XVNHG.js +92 -0
- package/dist/chunk-ZH6BHLQR.js +431 -0
- package/dist/chunk-ZP2E2H2G.cjs +119 -0
- package/dist/chunk-ZVWXM3UK.cjs +293 -0
- package/dist/close-button.type-BUYuoSt2.d.ts +36 -0
- package/dist/close-button.type-CHsgZ3wO.d.cts +36 -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/button/index.cjs +21 -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 +21 -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/input/index.cjs +25 -0
- package/dist/components/input/index.d.cts +205 -0
- package/dist/components/input/index.d.ts +205 -0
- package/dist/components/input/index.js +25 -0
- package/dist/components/input-group/index.cjs +27 -0
- package/dist/components/input-group/index.d.cts +270 -0
- package/dist/components/input-group/index.d.ts +270 -0
- package/dist/components/input-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/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/spinner/index.cjs +16 -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 +16 -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/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 +252 -4
- package/dist/index.d.cts +110 -4
- package/dist/index.d.ts +110 -4
- package/dist/index.js +271 -23
- package/dist/input.type-BUMDlzL9.d.cts +167 -0
- package/dist/input.type-D2qgi03E.d.ts +167 -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 +60 -3
- package/dist/system/index.d.cts +347 -181
- package/dist/system/index.d.ts +347 -181
- package/dist/system/index.js +71 -14
- package/dist/theme/index.cjs +4 -3
- package/dist/theme/index.d.cts +34 -23
- package/dist/theme/index.d.ts +34 -23
- package/dist/theme/index.js +3 -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 +184 -18
- package/dist/chunk-QAMNNTGM.js +0 -637
- package/dist/chunk-V63JO65F.cjs +0 -637
|
@@ -0,0 +1,145 @@
|
|
|
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 _chunkZP2E2H2Gcjs = require('./chunk-ZP2E2H2G.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkGLGU2WFLcjs = require('./chunk-GLGU2WFL.cjs');
|
|
7
|
+
|
|
8
|
+
// src/components/view/grid.tsx
|
|
9
|
+
var _react = require('react');
|
|
10
|
+
var _reactnative = require('react-native');
|
|
11
|
+
|
|
12
|
+
// src/components/view/grid.context.ts
|
|
13
|
+
|
|
14
|
+
var GridContext = _react.createContext.call(void 0, null);
|
|
15
|
+
var GridProvider = GridContext.Provider;
|
|
16
|
+
function useGrid() {
|
|
17
|
+
const value = _react.useContext.call(void 0, GridContext);
|
|
18
|
+
if (value === null) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
"XAUI: Grid.Item must be rendered inside a Grid \u2014 it spans that grid\u2019s columns, and outside one there is nothing to span."
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
function spanWidth({ cellWidth, columns, gap }, span) {
|
|
26
|
+
const clamped = Math.min(Math.max(Math.floor(span), 1), columns);
|
|
27
|
+
if (cellWidth === void 0) return `${100 / columns * clamped}%`;
|
|
28
|
+
return cellWidth * clamped + gap * (clamped - 1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/components/view/grid.tsx
|
|
32
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
33
|
+
var GridRoot = _react.forwardRef.call(void 0, function Grid({ children, columns = 2, gap = 0, style, onLayout, ...props }, ref) {
|
|
34
|
+
const [width, setWidth] = _react.useState.call(void 0, );
|
|
35
|
+
const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
|
|
36
|
+
const safeColumns = Math.max(Math.floor(columns), 1);
|
|
37
|
+
const cellWidth = width === void 0 ? void 0 : (width - gap * (safeColumns - 1)) / safeColumns;
|
|
38
|
+
const context = _react.useMemo.call(void 0,
|
|
39
|
+
() => ({ cellWidth, columns: safeColumns, gap }),
|
|
40
|
+
[cellWidth, safeColumns, gap]
|
|
41
|
+
);
|
|
42
|
+
const handleLayout = (event) => {
|
|
43
|
+
const next = event.nativeEvent.layout.width;
|
|
44
|
+
if (next > 0 && next !== width) setWidth(next);
|
|
45
|
+
_optionalChain([onLayout, 'optionalCall', _ => _(event)]);
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GridProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
48
|
+
_reactnative.View,
|
|
49
|
+
{
|
|
50
|
+
ref,
|
|
51
|
+
onLayout: handleLayout,
|
|
52
|
+
style: [
|
|
53
|
+
{ flexDirection: "row", flexWrap: "wrap", rowGap: gap, columnGap: gap },
|
|
54
|
+
styleProps,
|
|
55
|
+
style
|
|
56
|
+
],
|
|
57
|
+
...rest,
|
|
58
|
+
children: _react.Children.map(
|
|
59
|
+
children,
|
|
60
|
+
(child) => isGridItem(child) ? child : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { style: { width: spanWidth(context, 1) }, children: child })
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
) });
|
|
64
|
+
});
|
|
65
|
+
GridRoot.displayName = "XAUI.Grid";
|
|
66
|
+
function isGridItem(child) {
|
|
67
|
+
if (child === null || typeof child !== "object") return false;
|
|
68
|
+
const type = child.type;
|
|
69
|
+
return _optionalChain([type, 'optionalAccess', _2 => _2.displayName]) === "XAUI.Grid.Item";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/components/view/grid-item.tsx
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
var GridItem = _react.forwardRef.call(void 0, function GridItem2({ children, span = 1, style, ...props }, ref) {
|
|
77
|
+
const grid = useGrid();
|
|
78
|
+
const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
|
|
79
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
80
|
+
_reactnative.View,
|
|
81
|
+
{
|
|
82
|
+
ref,
|
|
83
|
+
style: [{ width: spanWidth(grid, span) }, styleProps, style],
|
|
84
|
+
...rest,
|
|
85
|
+
children
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
GridItem.displayName = "XAUI.Grid.Item";
|
|
90
|
+
|
|
91
|
+
// src/components/view/stack.tsx
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
var StackRoot = _react.forwardRef.call(void 0, function Stack({ children, asChild = false, style, ...props }, ref) {
|
|
96
|
+
const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
|
|
97
|
+
const Root = asChild ? _chunkZP2E2H2Gcjs.Slot : _reactnative.View;
|
|
98
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ref, style: [{ position: "relative" }, styleProps, style], ...rest, children });
|
|
99
|
+
});
|
|
100
|
+
StackRoot.displayName = "XAUI.Stack";
|
|
101
|
+
|
|
102
|
+
// src/components/view/stack-item.tsx
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
var StackItem = _react.forwardRef.call(void 0, function StackItem2({ children, asChild = false, style, ...props }, ref) {
|
|
107
|
+
const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
|
|
108
|
+
const Root = asChild ? _chunkZP2E2H2Gcjs.Slot : _reactnative.View;
|
|
109
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ref, style: [{ position: "absolute" }, styleProps, style], ...rest, children });
|
|
110
|
+
});
|
|
111
|
+
StackItem.displayName = "XAUI.Stack.Item";
|
|
112
|
+
|
|
113
|
+
// src/components/view/row.tsx
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
var Row = _react.forwardRef.call(void 0, function Row2({ children, asChild = false, style, ...props }, ref) {
|
|
118
|
+
const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
|
|
119
|
+
const Root = asChild ? _chunkZP2E2H2Gcjs.Slot : _reactnative.View;
|
|
120
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ref, style: [{ flexDirection: "row" }, styleProps, style], ...rest, children });
|
|
121
|
+
});
|
|
122
|
+
Row.displayName = "XAUI.Row";
|
|
123
|
+
|
|
124
|
+
// src/components/view/column.tsx
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
var Column = _react.forwardRef.call(void 0, function Column2({ children, asChild = false, style, ...props }, ref) {
|
|
129
|
+
const [styleProps, rest] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
|
|
130
|
+
const Root = asChild ? _chunkZP2E2H2Gcjs.Slot : _reactnative.View;
|
|
131
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ref, style: [{ flexDirection: "column" }, styleProps, style], ...rest, children });
|
|
132
|
+
});
|
|
133
|
+
Column.displayName = "XAUI.Column";
|
|
134
|
+
|
|
135
|
+
// src/components/view/index.ts
|
|
136
|
+
var Stack2 = Object.assign(StackRoot, { Item: StackItem });
|
|
137
|
+
var Grid2 = Object.assign(GridRoot, { Item: GridItem });
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
exports.useGrid = useGrid; exports.Row = Row; exports.Column = Column; exports.Stack = Stack2; exports.Grid = Grid2;
|
|
@@ -0,0 +1,62 @@
|
|
|
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 _chunkGLGU2WFLcjs = require('./chunk-GLGU2WFL.cjs');
|
|
4
|
+
|
|
5
|
+
// src/system/portal/portal.tsx
|
|
6
|
+
var _react = require('react');
|
|
7
|
+
|
|
8
|
+
// src/system/portal/portal-context.ts
|
|
9
|
+
|
|
10
|
+
var PortalContext = _react.createContext.call(void 0, null);
|
|
11
|
+
|
|
12
|
+
// src/system/portal/portal.tsx
|
|
13
|
+
function Portal({ children }) {
|
|
14
|
+
const context = _react.useContext.call(void 0, PortalContext);
|
|
15
|
+
const key = _react.useId.call(void 0, );
|
|
16
|
+
_react.useLayoutEffect.call(void 0, () => {
|
|
17
|
+
_optionalChain([context, 'optionalAccess', _ => _.addPortal, 'call', _2 => _2(key, children)]);
|
|
18
|
+
}, [children, context, key]);
|
|
19
|
+
_react.useLayoutEffect.call(void 0, () => {
|
|
20
|
+
return () => _optionalChain([context, 'optionalAccess', _3 => _3.removePortal, 'call', _4 => _4(key)]);
|
|
21
|
+
}, [context, key]);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
Portal.displayName = "XAUI.Portal";
|
|
25
|
+
|
|
26
|
+
// src/system/portal/portal-host.tsx
|
|
27
|
+
|
|
28
|
+
var _reactnative = require('react-native');
|
|
29
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
30
|
+
var styles = _reactnative.StyleSheet.create({
|
|
31
|
+
container: { flex: 1 }
|
|
32
|
+
});
|
|
33
|
+
function PortalHost({ children, ...props }) {
|
|
34
|
+
const [styleProps] = _chunkGLGU2WFLcjs.useStyleProps.call(void 0, props);
|
|
35
|
+
const [portals, setPortals] = _react.useState.call(void 0, /* @__PURE__ */ new Map());
|
|
36
|
+
const addPortal = _react.useCallback.call(void 0, (key, element) => {
|
|
37
|
+
setPortals((current) => new Map(current).set(key, element));
|
|
38
|
+
}, []);
|
|
39
|
+
const removePortal = _react.useCallback.call(void 0, (key) => {
|
|
40
|
+
setPortals((current) => {
|
|
41
|
+
if (!current.has(key)) return current;
|
|
42
|
+
const next = new Map(current);
|
|
43
|
+
next.delete(key);
|
|
44
|
+
return next;
|
|
45
|
+
});
|
|
46
|
+
}, []);
|
|
47
|
+
const methods = _react.useMemo.call(void 0,
|
|
48
|
+
() => ({ addPortal, removePortal }),
|
|
49
|
+
[addPortal, removePortal]
|
|
50
|
+
);
|
|
51
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PortalContext.Provider, { value: methods, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactnative.View, { style: [styles.container, styleProps], children: [
|
|
52
|
+
children,
|
|
53
|
+
Array.from(portals, ([key, element]) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: element }, key))
|
|
54
|
+
] }) });
|
|
55
|
+
}
|
|
56
|
+
PortalHost.displayName = "XAUI.PortalHost";
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
exports.PortalContext = PortalContext; exports.Portal = Portal; exports.PortalHost = PortalHost;
|
|
@@ -0,0 +1,92 @@
|
|
|
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-E2CWBQTV.js";
|
|
10
|
+
import {
|
|
11
|
+
useStyleProps
|
|
12
|
+
} from "./chunk-URSKA2VR.js";
|
|
13
|
+
|
|
14
|
+
// src/components/divider/divider.tsx
|
|
15
|
+
import { forwardRef } from "react";
|
|
16
|
+
import { View } from "react-native";
|
|
17
|
+
|
|
18
|
+
// src/components/divider/divider.recipe.ts
|
|
19
|
+
import { StyleSheet } from "react-native";
|
|
20
|
+
var SLOTS = ["root"];
|
|
21
|
+
var VARIANT_TOKENS = { default: { bg: "separator" } };
|
|
22
|
+
var HAIRLINE = StyleSheet.hairlineWidth;
|
|
23
|
+
function thickness(of) {
|
|
24
|
+
return (theme) => {
|
|
25
|
+
const value = of(theme);
|
|
26
|
+
return { root: { height: value, width: value } };
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var dividerRecipe = createRecipe({
|
|
30
|
+
slots: SLOTS,
|
|
31
|
+
base: () => ({
|
|
32
|
+
// One line for both orientations. In a column the cross axis is horizontal, so a
|
|
33
|
+
// stretched child is full width; in a row it is vertical, so the same word makes a
|
|
34
|
+
// vertical rule full height. `stretch` is ignored on the axis the thickness fixes,
|
|
35
|
+
// which is what lets one declaration serve both.
|
|
36
|
+
root: { alignSelf: "stretch" }
|
|
37
|
+
}),
|
|
38
|
+
variantTokens: VARIANT_TOKENS,
|
|
39
|
+
paint: (_theme, colors) => ({ root: { backgroundColor: colors.bg } }),
|
|
40
|
+
variants: {
|
|
41
|
+
// Multiples of `borderWidth.default`, so a theme that thickens its edges thickens
|
|
42
|
+
// these with it. Only the hairline stands outside the scale, being a device pixel.
|
|
43
|
+
size: {
|
|
44
|
+
xs: thickness(() => HAIRLINE),
|
|
45
|
+
sm: thickness((theme) => theme.borderWidth.default),
|
|
46
|
+
md: thickness((theme) => theme.borderWidth.default * 2),
|
|
47
|
+
lg: thickness((theme) => theme.borderWidth.default * 6)
|
|
48
|
+
},
|
|
49
|
+
/** Second, so it releases the axis `size` had to write blind. */
|
|
50
|
+
orientation: {
|
|
51
|
+
horizontal: () => ({ root: { width: "auto" } }),
|
|
52
|
+
vertical: () => ({ root: { height: "auto" } })
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* `xs` where every other component defaults to `md`, and it is the one place in the
|
|
57
|
+
* library that departs from that: a rule you notice is a rule that is too thick, and
|
|
58
|
+
* the hairline is what a separator is at rest.
|
|
59
|
+
*
|
|
60
|
+
* `variant` is named here and nowhere else — there is one, the caller cannot choose it,
|
|
61
|
+
* and the recipe still needs it selected for `paint` and the tint to resolve.
|
|
62
|
+
*/
|
|
63
|
+
defaultVariants: { variant: "default", size: "xs", orientation: "horizontal" }
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// src/components/divider/divider.tsx
|
|
67
|
+
import { jsx } from "react/jsx-runtime";
|
|
68
|
+
var Divider = forwardRef(function Divider2({ children, orientation, size, color, asChild = false, style, ...props }, ref) {
|
|
69
|
+
const theme = useXAUITheme();
|
|
70
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
71
|
+
const selection = { orientation, size };
|
|
72
|
+
const styles = dividerRecipe.resolve({ theme, selection });
|
|
73
|
+
const tint = color ? dividerRecipe.tint({ theme, color, selection }) : void 0;
|
|
74
|
+
const Root = asChild ? Slot : View;
|
|
75
|
+
return /* @__PURE__ */ jsx(
|
|
76
|
+
Root,
|
|
77
|
+
{
|
|
78
|
+
ref,
|
|
79
|
+
accessibilityElementsHidden: true,
|
|
80
|
+
importantForAccessibility: "no",
|
|
81
|
+
...rest,
|
|
82
|
+
style: [styles.root, tint?.root, styleProps, style],
|
|
83
|
+
children: asChild ? children : null
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
Divider.displayName = "XAUI.Divider";
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
dividerRecipe,
|
|
91
|
+
Divider
|
|
92
|
+
};
|