@xaui/native 0.2.5 → 0.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaui/native",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Flutter-inspired React Native UI components with native animations powered by React Native Reanimated",
5
5
  "keywords": [
6
6
  "react-native",
@@ -182,11 +182,6 @@
182
182
  "import": "./dist/card/index.js",
183
183
  "require": "./dist/card/index.js"
184
184
  },
185
- "./container": {
186
- "types": "./dist/container/index.d.ts",
187
- "import": "./dist/container/index.js",
188
- "require": "./dist/container/index.js"
189
- },
190
185
  "./input": {
191
186
  "types": "./dist/input/index.d.ts",
192
187
  "import": "./dist/input/index.js",
@@ -273,8 +268,8 @@
273
268
  "directory": "packages/native"
274
269
  },
275
270
  "dependencies": {
276
- "@xaui/core": "0.2.1",
277
- "@xaui/icons": "0.0.10"
271
+ "@xaui/core": "0.2.2",
272
+ "@xaui/icons": "0.0.11"
278
273
  },
279
274
  "peerDependencies": {
280
275
  "react": "^18.0.0 || ^19.0.0",
@@ -1,203 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; }// src/components/container/container.tsx
2
- var _react = require('react'); var _react2 = _interopRequireDefault(_react);
3
- var _reactnative = require('react-native');
4
-
5
- // src/components/container/container.utils.ts
6
- var resolveEdgeInsets = (value, prefix) => {
7
- if (typeof value === "number") {
8
- return prefix === "padding" ? { padding: value } : { margin: value };
9
- }
10
- const style = {};
11
- if (prefix === "padding") {
12
- if (value.horizontal !== void 0) style.paddingHorizontal = value.horizontal;
13
- if (value.vertical !== void 0) style.paddingVertical = value.vertical;
14
- if (value.top !== void 0) style.paddingTop = value.top;
15
- if (value.bottom !== void 0) style.paddingBottom = value.bottom;
16
- if (value.left !== void 0) style.paddingLeft = value.left;
17
- if (value.right !== void 0) style.paddingRight = value.right;
18
- } else {
19
- if (value.horizontal !== void 0) style.marginHorizontal = value.horizontal;
20
- if (value.vertical !== void 0) style.marginVertical = value.vertical;
21
- if (value.top !== void 0) style.marginTop = value.top;
22
- if (value.bottom !== void 0) style.marginBottom = value.bottom;
23
- if (value.left !== void 0) style.marginLeft = value.left;
24
- if (value.right !== void 0) style.marginRight = value.right;
25
- }
26
- return style;
27
- };
28
- var ALIGNMENT_MAP = {
29
- topLeft: { justifyContent: "flex-start", alignItems: "flex-start" },
30
- topCenter: { justifyContent: "flex-start", alignItems: "center" },
31
- topRight: { justifyContent: "flex-start", alignItems: "flex-end" },
32
- centerLeft: { justifyContent: "center", alignItems: "flex-start" },
33
- center: { justifyContent: "center", alignItems: "center" },
34
- centerRight: { justifyContent: "center", alignItems: "flex-end" },
35
- bottomLeft: { justifyContent: "flex-end", alignItems: "flex-start" },
36
- bottomCenter: { justifyContent: "flex-end", alignItems: "center" },
37
- bottomRight: { justifyContent: "flex-end", alignItems: "flex-end" }
38
- };
39
- var toFlexPosition = (v) => {
40
- if (v <= 0) return "flex-start";
41
- if (v >= 1) return "flex-end";
42
- return "center";
43
- };
44
- var resolveAlignment = (value) => {
45
- if (typeof value === "object") {
46
- return {
47
- justifyContent: toFlexPosition(value.y),
48
- alignItems: toFlexPosition(value.x)
49
- };
50
- }
51
- return _nullishCoalesce(ALIGNMENT_MAP[value], () => ( {
52
- justifyContent: "flex-start",
53
- alignItems: "flex-start"
54
- }));
55
- };
56
- var resolveBorderRadius = (value) => {
57
- if (typeof value === "number") {
58
- return { borderRadius: value };
59
- }
60
- const style = {};
61
- if (value.topLeft !== void 0) style.borderTopLeftRadius = value.topLeft;
62
- if (value.topRight !== void 0) style.borderTopRightRadius = value.topRight;
63
- if (value.bottomLeft !== void 0) style.borderBottomLeftRadius = value.bottomLeft;
64
- if (value.bottomRight !== void 0)
65
- style.borderBottomRightRadius = value.bottomRight;
66
- return style;
67
- };
68
- var resolveBorderSide = (side, position) => {
69
- const style = {};
70
- if (position === "") {
71
- if (side.width !== void 0) style.borderWidth = side.width;
72
- if (side.color !== void 0) style.borderColor = side.color;
73
- if (side.style !== void 0) style.borderStyle = side.style;
74
- return style;
75
- }
76
- if (position === "Top") {
77
- if (side.width !== void 0) style.borderTopWidth = side.width;
78
- if (side.color !== void 0) style.borderTopColor = side.color;
79
- } else if (position === "Bottom") {
80
- if (side.width !== void 0) style.borderBottomWidth = side.width;
81
- if (side.color !== void 0) style.borderBottomColor = side.color;
82
- } else if (position === "Left") {
83
- if (side.width !== void 0) style.borderLeftWidth = side.width;
84
- if (side.color !== void 0) style.borderLeftColor = side.color;
85
- } else {
86
- if (side.width !== void 0) style.borderRightWidth = side.width;
87
- if (side.color !== void 0) style.borderRightColor = side.color;
88
- }
89
- return style;
90
- };
91
- var resolveBorder = (value) => {
92
- const dir = value;
93
- if (dir.top !== void 0 || dir.bottom !== void 0 || dir.left !== void 0 || dir.right !== void 0) {
94
- return {
95
- ...dir.top ? resolveBorderSide(dir.top, "Top") : {},
96
- ...dir.bottom ? resolveBorderSide(dir.bottom, "Bottom") : {},
97
- ...dir.left ? resolveBorderSide(dir.left, "Left") : {},
98
- ...dir.right ? resolveBorderSide(dir.right, "Right") : {}
99
- };
100
- }
101
- return resolveBorderSide(value, "");
102
- };
103
- var resolveShadow = (value) => ({
104
- shadowColor: _nullishCoalesce(value.color, () => ( "#000000")),
105
- shadowOffset: {
106
- width: _nullishCoalesce(_optionalChain([value, 'access', _ => _.offset, 'optionalAccess', _2 => _2.x]), () => ( 0)),
107
- height: _nullishCoalesce(_optionalChain([value, 'access', _3 => _3.offset, 'optionalAccess', _4 => _4.y]), () => ( 4))
108
- },
109
- shadowOpacity: _nullishCoalesce(value.opacity, () => ( 0.1)),
110
- shadowRadius: _nullishCoalesce(value.blur, () => ( 4)),
111
- elevation: _nullishCoalesce(value.elevation, () => ( 2))
112
- });
113
- var resolveTransform = (value) => {
114
- const transforms = [];
115
- if (value.rotate !== void 0) transforms.push({ rotate: value.rotate });
116
- if (value.rotateX !== void 0) transforms.push({ rotateX: value.rotateX });
117
- if (value.rotateY !== void 0) transforms.push({ rotateY: value.rotateY });
118
- if (value.scale !== void 0) transforms.push({ scale: value.scale });
119
- if (value.scaleX !== void 0) transforms.push({ scaleX: value.scaleX });
120
- if (value.scaleY !== void 0) transforms.push({ scaleY: value.scaleY });
121
- if (value.translateX !== void 0)
122
- transforms.push({ translateX: value.translateX });
123
- if (value.translateY !== void 0)
124
- transforms.push({ translateY: value.translateY });
125
- if (value.skewX !== void 0) transforms.push({ skewX: value.skewX });
126
- if (value.skewY !== void 0) transforms.push({ skewY: value.skewY });
127
- return transforms;
128
- };
129
-
130
- // src/components/container/container.tsx
131
- var buildStyle = (props) => ({
132
- ...props.width !== void 0 && { width: props.width },
133
- ...props.height !== void 0 && { height: props.height },
134
- ...props.minWidth !== void 0 && { minWidth: props.minWidth },
135
- ...props.maxWidth !== void 0 && { maxWidth: props.maxWidth },
136
- ...props.minHeight !== void 0 && { minHeight: props.minHeight },
137
- ...props.maxHeight !== void 0 && { maxHeight: props.maxHeight },
138
- ...props.aspectRatio !== void 0 && { aspectRatio: props.aspectRatio },
139
- ...props.flex !== void 0 && { flex: props.flex },
140
- ...props.color !== void 0 && { backgroundColor: props.color },
141
- ...props.clip && { overflow: "hidden" },
142
- ...props.opacity !== void 0 && { opacity: props.opacity },
143
- ...props.padding !== void 0 && resolveEdgeInsets(props.padding, "padding"),
144
- ...props.margin !== void 0 && resolveEdgeInsets(props.margin, "margin"),
145
- ...props.alignment !== void 0 && resolveAlignment(props.alignment),
146
- ...props.borderRadius !== void 0 && resolveBorderRadius(props.borderRadius),
147
- ...props.border !== void 0 && resolveBorder(props.border),
148
- ...props.shadow !== void 0 && resolveShadow(props.shadow),
149
- ...props.transform !== void 0 && { transform: resolveTransform(props.transform) }
150
- });
151
- var Container = (props) => {
152
- const {
153
- children,
154
- onPress,
155
- onLongPress,
156
- onPressIn,
157
- onPressOut,
158
- disabled = false,
159
- accessibilityLabel,
160
- accessibilityRole,
161
- accessibilityState,
162
- accessible,
163
- testID,
164
- style
165
- } = props;
166
- const containerStyle = buildStyle(props);
167
- const isInteractive = !!(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(onPress, () => ( onLongPress)), () => ( onPressIn)), () => ( onPressOut)));
168
- if (isInteractive) {
169
- return /* @__PURE__ */ _react2.default.createElement(
170
- _reactnative.Pressable,
171
- {
172
- onPress: disabled ? void 0 : onPress,
173
- onLongPress: disabled ? void 0 : onLongPress,
174
- onPressIn: disabled ? void 0 : onPressIn,
175
- onPressOut: disabled ? void 0 : onPressOut,
176
- disabled,
177
- accessibilityLabel,
178
- accessibilityRole,
179
- accessibilityState,
180
- accessible,
181
- testID,
182
- style: [containerStyle, style]
183
- },
184
- children
185
- );
186
- }
187
- return /* @__PURE__ */ _react2.default.createElement(
188
- _reactnative.View,
189
- {
190
- accessibilityLabel,
191
- accessibilityRole,
192
- accessibilityState,
193
- accessible,
194
- testID,
195
- style: [containerStyle, style]
196
- },
197
- children
198
- );
199
- };
200
- Container.displayName = "Container";
201
-
202
-
203
- exports.Container = Container;
@@ -1,40 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { AccessibilityRole, AccessibilityState, StyleProp, ViewStyle } from 'react-native';
3
- import { EdgeInsets, Alignment, Border, BorderRadius, ShadowConfig, TransformConfig } from '@xaui/core';
4
-
5
- type ContainerProps = {
6
- children?: ReactNode;
7
- width?: number | `${number}%`;
8
- height?: number | `${number}%`;
9
- minWidth?: number;
10
- maxWidth?: number;
11
- minHeight?: number;
12
- maxHeight?: number;
13
- aspectRatio?: number;
14
- flex?: number;
15
- padding?: EdgeInsets;
16
- margin?: EdgeInsets;
17
- alignment?: Alignment;
18
- color?: string;
19
- border?: Border;
20
- borderRadius?: BorderRadius;
21
- shadow?: ShadowConfig;
22
- clip?: boolean;
23
- transform?: TransformConfig;
24
- opacity?: number;
25
- onPress?: () => void;
26
- onLongPress?: () => void;
27
- onPressIn?: () => void;
28
- onPressOut?: () => void;
29
- disabled?: boolean;
30
- accessibilityLabel?: string;
31
- accessibilityRole?: AccessibilityRole;
32
- accessibilityState?: AccessibilityState;
33
- accessible?: boolean;
34
- testID?: string;
35
- style?: StyleProp<ViewStyle>;
36
- };
37
-
38
- declare const Container: React.FC<ContainerProps>;
39
-
40
- export { Container, type ContainerProps };
@@ -1,40 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { AccessibilityRole, AccessibilityState, StyleProp, ViewStyle } from 'react-native';
3
- import { EdgeInsets, Alignment, Border, BorderRadius, ShadowConfig, TransformConfig } from '@xaui/core';
4
-
5
- type ContainerProps = {
6
- children?: ReactNode;
7
- width?: number | `${number}%`;
8
- height?: number | `${number}%`;
9
- minWidth?: number;
10
- maxWidth?: number;
11
- minHeight?: number;
12
- maxHeight?: number;
13
- aspectRatio?: number;
14
- flex?: number;
15
- padding?: EdgeInsets;
16
- margin?: EdgeInsets;
17
- alignment?: Alignment;
18
- color?: string;
19
- border?: Border;
20
- borderRadius?: BorderRadius;
21
- shadow?: ShadowConfig;
22
- clip?: boolean;
23
- transform?: TransformConfig;
24
- opacity?: number;
25
- onPress?: () => void;
26
- onLongPress?: () => void;
27
- onPressIn?: () => void;
28
- onPressOut?: () => void;
29
- disabled?: boolean;
30
- accessibilityLabel?: string;
31
- accessibilityRole?: AccessibilityRole;
32
- accessibilityState?: AccessibilityState;
33
- accessible?: boolean;
34
- testID?: string;
35
- style?: StyleProp<ViewStyle>;
36
- };
37
-
38
- declare const Container: React.FC<ContainerProps>;
39
-
40
- export { Container, type ContainerProps };
@@ -1,203 +0,0 @@
1
- // src/components/container/container.tsx
2
- import React from "react";
3
- import { View, Pressable } from "react-native";
4
-
5
- // src/components/container/container.utils.ts
6
- var resolveEdgeInsets = (value, prefix) => {
7
- if (typeof value === "number") {
8
- return prefix === "padding" ? { padding: value } : { margin: value };
9
- }
10
- const style = {};
11
- if (prefix === "padding") {
12
- if (value.horizontal !== void 0) style.paddingHorizontal = value.horizontal;
13
- if (value.vertical !== void 0) style.paddingVertical = value.vertical;
14
- if (value.top !== void 0) style.paddingTop = value.top;
15
- if (value.bottom !== void 0) style.paddingBottom = value.bottom;
16
- if (value.left !== void 0) style.paddingLeft = value.left;
17
- if (value.right !== void 0) style.paddingRight = value.right;
18
- } else {
19
- if (value.horizontal !== void 0) style.marginHorizontal = value.horizontal;
20
- if (value.vertical !== void 0) style.marginVertical = value.vertical;
21
- if (value.top !== void 0) style.marginTop = value.top;
22
- if (value.bottom !== void 0) style.marginBottom = value.bottom;
23
- if (value.left !== void 0) style.marginLeft = value.left;
24
- if (value.right !== void 0) style.marginRight = value.right;
25
- }
26
- return style;
27
- };
28
- var ALIGNMENT_MAP = {
29
- topLeft: { justifyContent: "flex-start", alignItems: "flex-start" },
30
- topCenter: { justifyContent: "flex-start", alignItems: "center" },
31
- topRight: { justifyContent: "flex-start", alignItems: "flex-end" },
32
- centerLeft: { justifyContent: "center", alignItems: "flex-start" },
33
- center: { justifyContent: "center", alignItems: "center" },
34
- centerRight: { justifyContent: "center", alignItems: "flex-end" },
35
- bottomLeft: { justifyContent: "flex-end", alignItems: "flex-start" },
36
- bottomCenter: { justifyContent: "flex-end", alignItems: "center" },
37
- bottomRight: { justifyContent: "flex-end", alignItems: "flex-end" }
38
- };
39
- var toFlexPosition = (v) => {
40
- if (v <= 0) return "flex-start";
41
- if (v >= 1) return "flex-end";
42
- return "center";
43
- };
44
- var resolveAlignment = (value) => {
45
- if (typeof value === "object") {
46
- return {
47
- justifyContent: toFlexPosition(value.y),
48
- alignItems: toFlexPosition(value.x)
49
- };
50
- }
51
- return ALIGNMENT_MAP[value] ?? {
52
- justifyContent: "flex-start",
53
- alignItems: "flex-start"
54
- };
55
- };
56
- var resolveBorderRadius = (value) => {
57
- if (typeof value === "number") {
58
- return { borderRadius: value };
59
- }
60
- const style = {};
61
- if (value.topLeft !== void 0) style.borderTopLeftRadius = value.topLeft;
62
- if (value.topRight !== void 0) style.borderTopRightRadius = value.topRight;
63
- if (value.bottomLeft !== void 0) style.borderBottomLeftRadius = value.bottomLeft;
64
- if (value.bottomRight !== void 0)
65
- style.borderBottomRightRadius = value.bottomRight;
66
- return style;
67
- };
68
- var resolveBorderSide = (side, position) => {
69
- const style = {};
70
- if (position === "") {
71
- if (side.width !== void 0) style.borderWidth = side.width;
72
- if (side.color !== void 0) style.borderColor = side.color;
73
- if (side.style !== void 0) style.borderStyle = side.style;
74
- return style;
75
- }
76
- if (position === "Top") {
77
- if (side.width !== void 0) style.borderTopWidth = side.width;
78
- if (side.color !== void 0) style.borderTopColor = side.color;
79
- } else if (position === "Bottom") {
80
- if (side.width !== void 0) style.borderBottomWidth = side.width;
81
- if (side.color !== void 0) style.borderBottomColor = side.color;
82
- } else if (position === "Left") {
83
- if (side.width !== void 0) style.borderLeftWidth = side.width;
84
- if (side.color !== void 0) style.borderLeftColor = side.color;
85
- } else {
86
- if (side.width !== void 0) style.borderRightWidth = side.width;
87
- if (side.color !== void 0) style.borderRightColor = side.color;
88
- }
89
- return style;
90
- };
91
- var resolveBorder = (value) => {
92
- const dir = value;
93
- if (dir.top !== void 0 || dir.bottom !== void 0 || dir.left !== void 0 || dir.right !== void 0) {
94
- return {
95
- ...dir.top ? resolveBorderSide(dir.top, "Top") : {},
96
- ...dir.bottom ? resolveBorderSide(dir.bottom, "Bottom") : {},
97
- ...dir.left ? resolveBorderSide(dir.left, "Left") : {},
98
- ...dir.right ? resolveBorderSide(dir.right, "Right") : {}
99
- };
100
- }
101
- return resolveBorderSide(value, "");
102
- };
103
- var resolveShadow = (value) => ({
104
- shadowColor: value.color ?? "#000000",
105
- shadowOffset: {
106
- width: value.offset?.x ?? 0,
107
- height: value.offset?.y ?? 4
108
- },
109
- shadowOpacity: value.opacity ?? 0.1,
110
- shadowRadius: value.blur ?? 4,
111
- elevation: value.elevation ?? 2
112
- });
113
- var resolveTransform = (value) => {
114
- const transforms = [];
115
- if (value.rotate !== void 0) transforms.push({ rotate: value.rotate });
116
- if (value.rotateX !== void 0) transforms.push({ rotateX: value.rotateX });
117
- if (value.rotateY !== void 0) transforms.push({ rotateY: value.rotateY });
118
- if (value.scale !== void 0) transforms.push({ scale: value.scale });
119
- if (value.scaleX !== void 0) transforms.push({ scaleX: value.scaleX });
120
- if (value.scaleY !== void 0) transforms.push({ scaleY: value.scaleY });
121
- if (value.translateX !== void 0)
122
- transforms.push({ translateX: value.translateX });
123
- if (value.translateY !== void 0)
124
- transforms.push({ translateY: value.translateY });
125
- if (value.skewX !== void 0) transforms.push({ skewX: value.skewX });
126
- if (value.skewY !== void 0) transforms.push({ skewY: value.skewY });
127
- return transforms;
128
- };
129
-
130
- // src/components/container/container.tsx
131
- var buildStyle = (props) => ({
132
- ...props.width !== void 0 && { width: props.width },
133
- ...props.height !== void 0 && { height: props.height },
134
- ...props.minWidth !== void 0 && { minWidth: props.minWidth },
135
- ...props.maxWidth !== void 0 && { maxWidth: props.maxWidth },
136
- ...props.minHeight !== void 0 && { minHeight: props.minHeight },
137
- ...props.maxHeight !== void 0 && { maxHeight: props.maxHeight },
138
- ...props.aspectRatio !== void 0 && { aspectRatio: props.aspectRatio },
139
- ...props.flex !== void 0 && { flex: props.flex },
140
- ...props.color !== void 0 && { backgroundColor: props.color },
141
- ...props.clip && { overflow: "hidden" },
142
- ...props.opacity !== void 0 && { opacity: props.opacity },
143
- ...props.padding !== void 0 && resolveEdgeInsets(props.padding, "padding"),
144
- ...props.margin !== void 0 && resolveEdgeInsets(props.margin, "margin"),
145
- ...props.alignment !== void 0 && resolveAlignment(props.alignment),
146
- ...props.borderRadius !== void 0 && resolveBorderRadius(props.borderRadius),
147
- ...props.border !== void 0 && resolveBorder(props.border),
148
- ...props.shadow !== void 0 && resolveShadow(props.shadow),
149
- ...props.transform !== void 0 && { transform: resolveTransform(props.transform) }
150
- });
151
- var Container = (props) => {
152
- const {
153
- children,
154
- onPress,
155
- onLongPress,
156
- onPressIn,
157
- onPressOut,
158
- disabled = false,
159
- accessibilityLabel,
160
- accessibilityRole,
161
- accessibilityState,
162
- accessible,
163
- testID,
164
- style
165
- } = props;
166
- const containerStyle = buildStyle(props);
167
- const isInteractive = !!(onPress ?? onLongPress ?? onPressIn ?? onPressOut);
168
- if (isInteractive) {
169
- return /* @__PURE__ */ React.createElement(
170
- Pressable,
171
- {
172
- onPress: disabled ? void 0 : onPress,
173
- onLongPress: disabled ? void 0 : onLongPress,
174
- onPressIn: disabled ? void 0 : onPressIn,
175
- onPressOut: disabled ? void 0 : onPressOut,
176
- disabled,
177
- accessibilityLabel,
178
- accessibilityRole,
179
- accessibilityState,
180
- accessible,
181
- testID,
182
- style: [containerStyle, style]
183
- },
184
- children
185
- );
186
- }
187
- return /* @__PURE__ */ React.createElement(
188
- View,
189
- {
190
- accessibilityLabel,
191
- accessibilityRole,
192
- accessibilityState,
193
- accessible,
194
- testID,
195
- style: [containerStyle, style]
196
- },
197
- children
198
- );
199
- };
200
- Container.displayName = "Container";
201
- export {
202
- Container
203
- };