@xaui/native 0.0.9 → 0.0.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.
- package/dist/accordion/index.cjs +29 -26
- package/dist/accordion/index.d.cts +48 -36
- package/dist/accordion/index.d.ts +48 -36
- package/dist/accordion/index.js +27 -24
- package/dist/alert/index.cjs +593 -0
- package/dist/alert/index.d.cts +90 -0
- package/dist/alert/index.d.ts +90 -0
- package/dist/alert/index.js +8 -0
- package/dist/autocomplete/index.cjs +6 -8
- package/dist/autocomplete/index.d.cts +22 -4
- package/dist/autocomplete/index.d.ts +22 -4
- package/dist/autocomplete/index.js +3 -2
- package/dist/chunk-OFYJYQ2M.js +358 -0
- package/dist/{chunk-7LXW4BXD.js → chunk-RE3CO277.js} +4 -166
- package/dist/chunk-SIXET7TJ.js +172 -0
- package/dist/{chunk-6HUSEZDJ.js → chunk-SVYTCEGB.js} +10 -10
- package/dist/icon/index.js +4 -2
- package/dist/index.cjs +707 -358
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -2
- package/package.json +6 -1
package/dist/accordion/index.cjs
CHANGED
|
@@ -97,7 +97,10 @@ function useXUIPalette() {
|
|
|
97
97
|
var import_theme2 = require("@xaui/core/theme");
|
|
98
98
|
|
|
99
99
|
// src/components/accordion/accordion.hook.ts
|
|
100
|
-
var useAccordionStyles = ({
|
|
100
|
+
var useAccordionStyles = ({
|
|
101
|
+
variant,
|
|
102
|
+
fullWidth
|
|
103
|
+
}) => {
|
|
101
104
|
const theme = useXUITheme();
|
|
102
105
|
const palette2 = useXUIPalette();
|
|
103
106
|
const containerStyles = (0, import_react7.useMemo)(() => {
|
|
@@ -109,7 +112,7 @@ var useAccordionStyles = ({ variant, fullWidth }) => {
|
|
|
109
112
|
base.borderWidth = theme.borderWidth.md;
|
|
110
113
|
base.borderColor = theme.mode === "dark" ? palette2.gray[800] : theme.palette.gray[200];
|
|
111
114
|
base.borderRadius = theme.borderRadius.md;
|
|
112
|
-
base.
|
|
115
|
+
base.paddingHorizontal = theme.spacing.sm;
|
|
113
116
|
base.overflow = "hidden";
|
|
114
117
|
} else if (variant === "light") {
|
|
115
118
|
base.paddingHorizontal = theme.spacing.sm;
|
|
@@ -205,6 +208,7 @@ var styles = import_react_native4.StyleSheet.create({
|
|
|
205
208
|
var import_react8 = require("react");
|
|
206
209
|
var import_react_native5 = require("react-native");
|
|
207
210
|
var import_palette2 = require("@xaui/core/palette");
|
|
211
|
+
var import_core3 = require("@xaui/core");
|
|
208
212
|
var useAccordionItemState = (itemKey) => {
|
|
209
213
|
const context = useAccordionContext();
|
|
210
214
|
const resolvedItemKey = itemKey ?? "";
|
|
@@ -284,9 +288,9 @@ var useBaseStyles = (variant, isDisabled) => {
|
|
|
284
288
|
const base = { overflow: "hidden" };
|
|
285
289
|
if (variant === "splitted") {
|
|
286
290
|
base.paddingHorizontal = theme.spacing.md;
|
|
287
|
-
base.backgroundColor = theme.colors.default.background;
|
|
291
|
+
base.backgroundColor = (0, import_core3.addOpacityToColor)(theme.colors.default.background, 0.5);
|
|
288
292
|
base.borderRadius = theme.borderRadius.md;
|
|
289
|
-
base.marginBottom = theme.spacing.
|
|
293
|
+
base.marginBottom = theme.spacing.xs;
|
|
290
294
|
} else if (variant === "bordered") {
|
|
291
295
|
base.paddingHorizontal = theme.spacing.md;
|
|
292
296
|
}
|
|
@@ -341,7 +345,7 @@ var useContentContainerStyle = (isCompact, variant) => {
|
|
|
341
345
|
const theme = useXUITheme();
|
|
342
346
|
const contentContainerStyle = (0, import_react8.useMemo)(
|
|
343
347
|
() => ({
|
|
344
|
-
paddingBottom: isCompact ? theme.spacing.
|
|
348
|
+
paddingBottom: isCompact ? theme.spacing.xs : theme.spacing.sm,
|
|
345
349
|
paddingHorizontal: variant === "light" ? theme.spacing.sm : 0
|
|
346
350
|
}),
|
|
347
351
|
[isCompact, variant, theme]
|
|
@@ -380,14 +384,7 @@ var AccordionItem = ({
|
|
|
380
384
|
subtitle,
|
|
381
385
|
startContent,
|
|
382
386
|
indicator,
|
|
383
|
-
|
|
384
|
-
headingStyle,
|
|
385
|
-
triggerStyle,
|
|
386
|
-
titleStyle,
|
|
387
|
-
subtitleStyle,
|
|
388
|
-
contentStyle,
|
|
389
|
-
startContentStyle,
|
|
390
|
-
indicatorStyle,
|
|
387
|
+
customAppearance,
|
|
391
388
|
onSelected
|
|
392
389
|
}) => {
|
|
393
390
|
const {
|
|
@@ -410,29 +407,36 @@ var AccordionItem = ({
|
|
|
410
407
|
const subtitleTextStyle = useSubtitleTextStyle();
|
|
411
408
|
const contentContainerStyle = useContentContainerStyle(isCompact, variant);
|
|
412
409
|
const foregroundColor = useForegroundColor();
|
|
413
|
-
return /* @__PURE__ */ import_react10.default.createElement(import_react_native6.View, { style: [baseStyles,
|
|
410
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_react_native6.View, { style: [baseStyles, customAppearance?.base] }, /* @__PURE__ */ import_react10.default.createElement(import_react_native6.View, { style: customAppearance?.heading }, /* @__PURE__ */ import_react10.default.createElement(
|
|
414
411
|
import_react_native6.Pressable,
|
|
415
412
|
{
|
|
416
|
-
style: [triggerStyles,
|
|
413
|
+
style: [triggerStyles, customAppearance?.trigger],
|
|
417
414
|
onPress: handlePress,
|
|
418
415
|
disabled: isDisabled,
|
|
419
416
|
accessibilityRole: "button",
|
|
420
417
|
accessibilityState: { expanded: isExpanded, disabled: isDisabled }
|
|
421
418
|
},
|
|
422
|
-
startContent && /* @__PURE__ */ import_react10.default.createElement(import_react_native6.View, { style: [styles.startContent,
|
|
423
|
-
/* @__PURE__ */ import_react10.default.createElement(import_react_native6.View, { style: styles.titleWrapper }, typeof title === "string" ? /* @__PURE__ */ import_react10.default.createElement(import_react_native6.Text, { style: [titleTextStyle,
|
|
419
|
+
startContent && /* @__PURE__ */ import_react10.default.createElement(import_react_native6.View, { style: [styles.startContent, customAppearance?.startContent] }, startContent),
|
|
420
|
+
/* @__PURE__ */ import_react10.default.createElement(import_react_native6.View, { style: styles.titleWrapper }, typeof title === "string" ? /* @__PURE__ */ import_react10.default.createElement(import_react_native6.Text, { style: [titleTextStyle, customAppearance?.title] }, title) : title, subtitle && (typeof subtitle === "string" ? /* @__PURE__ */ import_react10.default.createElement(import_react_native6.Text, { style: [subtitleTextStyle, customAppearance?.subtitle] }, subtitle) : subtitle)),
|
|
424
421
|
!hideIndicator && /* @__PURE__ */ import_react10.default.createElement(
|
|
425
422
|
import_react_native6.Animated.View,
|
|
426
423
|
{
|
|
427
424
|
style: [
|
|
428
425
|
styles.indicator,
|
|
429
|
-
|
|
426
|
+
customAppearance?.indicator,
|
|
430
427
|
{ transform: [{ rotate: rotationInterpolation }] }
|
|
431
428
|
]
|
|
432
429
|
},
|
|
433
430
|
indicator || /* @__PURE__ */ import_react10.default.createElement(ChevronRightIcon, { color: foregroundColor })
|
|
434
431
|
)
|
|
435
|
-
)), /* @__PURE__ */ import_react10.default.createElement(import_react_native6.View, { style: styles.hiddenMeasure, pointerEvents: "none" }, /* @__PURE__ */ import_react10.default.createElement(
|
|
432
|
+
)), /* @__PURE__ */ import_react10.default.createElement(import_react_native6.View, { style: styles.hiddenMeasure, pointerEvents: "none" }, /* @__PURE__ */ import_react10.default.createElement(
|
|
433
|
+
import_react_native6.View,
|
|
434
|
+
{
|
|
435
|
+
onLayout: onContentLayout,
|
|
436
|
+
style: [contentContainerStyle, customAppearance?.content]
|
|
437
|
+
},
|
|
438
|
+
children
|
|
439
|
+
)), /* @__PURE__ */ import_react10.default.createElement(
|
|
436
440
|
import_react_native6.Animated.View,
|
|
437
441
|
{
|
|
438
442
|
style: [
|
|
@@ -440,7 +444,7 @@ var AccordionItem = ({
|
|
|
440
444
|
disableAnimation ? { height: isExpanded ? void 0 : 0 } : { height: heightInterpolation }
|
|
441
445
|
]
|
|
442
446
|
},
|
|
443
|
-
/* @__PURE__ */ import_react10.default.createElement(import_react_native6.View, { style: [contentContainerStyle,
|
|
447
|
+
/* @__PURE__ */ import_react10.default.createElement(import_react_native6.View, { style: [contentContainerStyle, customAppearance?.content] }, children)
|
|
444
448
|
));
|
|
445
449
|
};
|
|
446
450
|
AccordionItem.displayName = "AccordionItem";
|
|
@@ -493,14 +497,14 @@ var styles2 = import_react_native7.StyleSheet.create({
|
|
|
493
497
|
|
|
494
498
|
// src/components/divider/divider.hook.ts
|
|
495
499
|
var import_react12 = require("react");
|
|
496
|
-
var
|
|
500
|
+
var import_core5 = require("@xaui/core");
|
|
497
501
|
var useDividerColor = (themeColor, customColor) => {
|
|
498
502
|
const theme = useXUITheme();
|
|
499
503
|
const dividerColor = (0, import_react12.useMemo)(() => {
|
|
500
504
|
if (customColor) {
|
|
501
505
|
return customColor;
|
|
502
506
|
}
|
|
503
|
-
const safeThemeColor = (0,
|
|
507
|
+
const safeThemeColor = (0, import_core5.getSafeThemeColor)(themeColor);
|
|
504
508
|
return theme.colors[safeThemeColor].main;
|
|
505
509
|
}, [customColor, themeColor, theme]);
|
|
506
510
|
return dividerColor;
|
|
@@ -547,8 +551,7 @@ var Accordion = (props) => {
|
|
|
547
551
|
variant = "light",
|
|
548
552
|
showDivider = false,
|
|
549
553
|
fullWidth = true,
|
|
550
|
-
|
|
551
|
-
itemStyle
|
|
554
|
+
customAppearance
|
|
552
555
|
} = props;
|
|
553
556
|
const { containerStyles, dividerColor } = useAccordionStyles({
|
|
554
557
|
variant,
|
|
@@ -557,14 +560,14 @@ var Accordion = (props) => {
|
|
|
557
560
|
const contextParams = buildAccordionContextParams(props);
|
|
558
561
|
const contextValue = useAccordionContextValue(contextParams);
|
|
559
562
|
const childrenArray = import_react14.default.Children.toArray(children);
|
|
560
|
-
return /* @__PURE__ */ import_react14.default.createElement(AccordionContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react14.default.createElement(import_react_native9.View, { style: [containerStyles,
|
|
563
|
+
return /* @__PURE__ */ import_react14.default.createElement(AccordionContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react14.default.createElement(import_react_native9.View, { style: [containerStyles, customAppearance?.container] }, childrenArray.map((child, index) => {
|
|
561
564
|
const isLast = index === childrenArray.length - 1;
|
|
562
565
|
const showBottomDivider = (showDivider || variant === "bordered") && !isLast && variant !== "splitted";
|
|
563
566
|
const resolvedChildKey = isAccordionItem(child) ? getItemKey(child.props.itemKey ?? normalizeElementKey(child.key), index) : getItemKey(
|
|
564
567
|
import_react14.default.isValidElement(child) ? normalizeElementKey(child.key) : void 0,
|
|
565
568
|
index
|
|
566
569
|
);
|
|
567
|
-
return /* @__PURE__ */ import_react14.default.createElement(import_react_native9.View, { key: resolvedChildKey, style:
|
|
570
|
+
return /* @__PURE__ */ import_react14.default.createElement(import_react_native9.View, { key: resolvedChildKey, style: customAppearance?.item }, isAccordionItem(child) ? import_react14.default.cloneElement(child, { itemKey: resolvedChildKey }) : child, showBottomDivider && /* @__PURE__ */ import_react14.default.createElement(Divider, { color: dividerColor, size: 2 }));
|
|
568
571
|
})));
|
|
569
572
|
};
|
|
570
573
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -6,6 +6,16 @@ type AccordionSelectionMode = 'toggle' | 'multiple';
|
|
|
6
6
|
type AccordionEvents = {
|
|
7
7
|
onSelectionChange?: (selectedKeys: string[]) => void;
|
|
8
8
|
};
|
|
9
|
+
type AccordionCustomAppearance = {
|
|
10
|
+
/**
|
|
11
|
+
* Custom styles for the container
|
|
12
|
+
*/
|
|
13
|
+
container?: ViewStyle;
|
|
14
|
+
/**
|
|
15
|
+
* Custom styles for individual items
|
|
16
|
+
*/
|
|
17
|
+
item?: ViewStyle;
|
|
18
|
+
};
|
|
9
19
|
type AccordionProps = {
|
|
10
20
|
/**
|
|
11
21
|
* List of AccordionItem components
|
|
@@ -62,13 +72,9 @@ type AccordionProps = {
|
|
|
62
72
|
*/
|
|
63
73
|
isCompact?: boolean;
|
|
64
74
|
/**
|
|
65
|
-
* Custom styles for
|
|
75
|
+
* Custom appearance styles for all accordion parts
|
|
66
76
|
*/
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Custom styles for individual items
|
|
70
|
-
*/
|
|
71
|
-
itemStyle?: ViewStyle;
|
|
77
|
+
customAppearance?: AccordionCustomAppearance;
|
|
72
78
|
} & AccordionEvents;
|
|
73
79
|
|
|
74
80
|
declare const Accordion: React.FC<AccordionProps>;
|
|
@@ -76,64 +82,70 @@ declare const Accordion: React.FC<AccordionProps>;
|
|
|
76
82
|
type AccordionItemEvents = {
|
|
77
83
|
onSelected?: (isSelected: boolean) => void;
|
|
78
84
|
};
|
|
79
|
-
type
|
|
85
|
+
type AccordionItemCustomAppearance = {
|
|
80
86
|
/**
|
|
81
|
-
*
|
|
87
|
+
* Custom styles for the base container
|
|
82
88
|
*/
|
|
83
|
-
|
|
89
|
+
base?: ViewStyle;
|
|
84
90
|
/**
|
|
85
|
-
*
|
|
91
|
+
* Custom styles for the header container
|
|
86
92
|
*/
|
|
87
|
-
|
|
93
|
+
heading?: ViewStyle;
|
|
88
94
|
/**
|
|
89
|
-
*
|
|
95
|
+
* Custom styles for the trigger button
|
|
90
96
|
*/
|
|
91
|
-
|
|
97
|
+
trigger?: ViewStyle;
|
|
92
98
|
/**
|
|
93
|
-
*
|
|
99
|
+
* Custom styles for the title text
|
|
94
100
|
*/
|
|
95
|
-
|
|
101
|
+
title?: TextStyle;
|
|
96
102
|
/**
|
|
97
|
-
*
|
|
103
|
+
* Custom styles for the subtitle text
|
|
98
104
|
*/
|
|
99
|
-
|
|
105
|
+
subtitle?: TextStyle;
|
|
100
106
|
/**
|
|
101
|
-
* Custom
|
|
102
|
-
* @default ChevronRight icon
|
|
107
|
+
* Custom styles for the content container
|
|
103
108
|
*/
|
|
104
|
-
|
|
109
|
+
content?: ViewStyle;
|
|
105
110
|
/**
|
|
106
|
-
* Custom styles for the
|
|
111
|
+
* Custom styles for the start content container
|
|
107
112
|
*/
|
|
108
|
-
|
|
113
|
+
startContent?: ViewStyle;
|
|
109
114
|
/**
|
|
110
|
-
* Custom styles for the
|
|
115
|
+
* Custom styles for the indicator
|
|
111
116
|
*/
|
|
112
|
-
|
|
117
|
+
indicator?: ViewStyle;
|
|
118
|
+
};
|
|
119
|
+
type AccordionItemProps = {
|
|
113
120
|
/**
|
|
114
|
-
*
|
|
121
|
+
* Unique key for the accordion item
|
|
115
122
|
*/
|
|
116
|
-
|
|
123
|
+
itemKey?: string;
|
|
117
124
|
/**
|
|
118
|
-
*
|
|
125
|
+
* Content to display when accordion item is expanded
|
|
119
126
|
*/
|
|
120
|
-
|
|
127
|
+
children: ReactNode;
|
|
121
128
|
/**
|
|
122
|
-
*
|
|
129
|
+
* Title displayed in the accordion header
|
|
123
130
|
*/
|
|
124
|
-
|
|
131
|
+
title: ReactNode;
|
|
125
132
|
/**
|
|
126
|
-
*
|
|
133
|
+
* Optional subtitle displayed below the title
|
|
127
134
|
*/
|
|
128
|
-
|
|
135
|
+
subtitle?: ReactNode;
|
|
129
136
|
/**
|
|
130
|
-
*
|
|
137
|
+
* Content displayed at the start of the header (left side)
|
|
131
138
|
*/
|
|
132
|
-
|
|
139
|
+
startContent?: ReactNode;
|
|
133
140
|
/**
|
|
134
|
-
* Custom
|
|
141
|
+
* Custom indicator for the expanded/collapsed state
|
|
142
|
+
* @default ChevronRight icon
|
|
143
|
+
*/
|
|
144
|
+
indicator?: ReactNode;
|
|
145
|
+
/**
|
|
146
|
+
* Custom appearance styles for all accordion item parts
|
|
135
147
|
*/
|
|
136
|
-
|
|
148
|
+
customAppearance?: AccordionItemCustomAppearance;
|
|
137
149
|
} & AccordionItemEvents;
|
|
138
150
|
|
|
139
151
|
declare const AccordionItem: React.FC<AccordionItemProps>;
|
|
@@ -6,6 +6,16 @@ type AccordionSelectionMode = 'toggle' | 'multiple';
|
|
|
6
6
|
type AccordionEvents = {
|
|
7
7
|
onSelectionChange?: (selectedKeys: string[]) => void;
|
|
8
8
|
};
|
|
9
|
+
type AccordionCustomAppearance = {
|
|
10
|
+
/**
|
|
11
|
+
* Custom styles for the container
|
|
12
|
+
*/
|
|
13
|
+
container?: ViewStyle;
|
|
14
|
+
/**
|
|
15
|
+
* Custom styles for individual items
|
|
16
|
+
*/
|
|
17
|
+
item?: ViewStyle;
|
|
18
|
+
};
|
|
9
19
|
type AccordionProps = {
|
|
10
20
|
/**
|
|
11
21
|
* List of AccordionItem components
|
|
@@ -62,13 +72,9 @@ type AccordionProps = {
|
|
|
62
72
|
*/
|
|
63
73
|
isCompact?: boolean;
|
|
64
74
|
/**
|
|
65
|
-
* Custom styles for
|
|
75
|
+
* Custom appearance styles for all accordion parts
|
|
66
76
|
*/
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Custom styles for individual items
|
|
70
|
-
*/
|
|
71
|
-
itemStyle?: ViewStyle;
|
|
77
|
+
customAppearance?: AccordionCustomAppearance;
|
|
72
78
|
} & AccordionEvents;
|
|
73
79
|
|
|
74
80
|
declare const Accordion: React.FC<AccordionProps>;
|
|
@@ -76,64 +82,70 @@ declare const Accordion: React.FC<AccordionProps>;
|
|
|
76
82
|
type AccordionItemEvents = {
|
|
77
83
|
onSelected?: (isSelected: boolean) => void;
|
|
78
84
|
};
|
|
79
|
-
type
|
|
85
|
+
type AccordionItemCustomAppearance = {
|
|
80
86
|
/**
|
|
81
|
-
*
|
|
87
|
+
* Custom styles for the base container
|
|
82
88
|
*/
|
|
83
|
-
|
|
89
|
+
base?: ViewStyle;
|
|
84
90
|
/**
|
|
85
|
-
*
|
|
91
|
+
* Custom styles for the header container
|
|
86
92
|
*/
|
|
87
|
-
|
|
93
|
+
heading?: ViewStyle;
|
|
88
94
|
/**
|
|
89
|
-
*
|
|
95
|
+
* Custom styles for the trigger button
|
|
90
96
|
*/
|
|
91
|
-
|
|
97
|
+
trigger?: ViewStyle;
|
|
92
98
|
/**
|
|
93
|
-
*
|
|
99
|
+
* Custom styles for the title text
|
|
94
100
|
*/
|
|
95
|
-
|
|
101
|
+
title?: TextStyle;
|
|
96
102
|
/**
|
|
97
|
-
*
|
|
103
|
+
* Custom styles for the subtitle text
|
|
98
104
|
*/
|
|
99
|
-
|
|
105
|
+
subtitle?: TextStyle;
|
|
100
106
|
/**
|
|
101
|
-
* Custom
|
|
102
|
-
* @default ChevronRight icon
|
|
107
|
+
* Custom styles for the content container
|
|
103
108
|
*/
|
|
104
|
-
|
|
109
|
+
content?: ViewStyle;
|
|
105
110
|
/**
|
|
106
|
-
* Custom styles for the
|
|
111
|
+
* Custom styles for the start content container
|
|
107
112
|
*/
|
|
108
|
-
|
|
113
|
+
startContent?: ViewStyle;
|
|
109
114
|
/**
|
|
110
|
-
* Custom styles for the
|
|
115
|
+
* Custom styles for the indicator
|
|
111
116
|
*/
|
|
112
|
-
|
|
117
|
+
indicator?: ViewStyle;
|
|
118
|
+
};
|
|
119
|
+
type AccordionItemProps = {
|
|
113
120
|
/**
|
|
114
|
-
*
|
|
121
|
+
* Unique key for the accordion item
|
|
115
122
|
*/
|
|
116
|
-
|
|
123
|
+
itemKey?: string;
|
|
117
124
|
/**
|
|
118
|
-
*
|
|
125
|
+
* Content to display when accordion item is expanded
|
|
119
126
|
*/
|
|
120
|
-
|
|
127
|
+
children: ReactNode;
|
|
121
128
|
/**
|
|
122
|
-
*
|
|
129
|
+
* Title displayed in the accordion header
|
|
123
130
|
*/
|
|
124
|
-
|
|
131
|
+
title: ReactNode;
|
|
125
132
|
/**
|
|
126
|
-
*
|
|
133
|
+
* Optional subtitle displayed below the title
|
|
127
134
|
*/
|
|
128
|
-
|
|
135
|
+
subtitle?: ReactNode;
|
|
129
136
|
/**
|
|
130
|
-
*
|
|
137
|
+
* Content displayed at the start of the header (left side)
|
|
131
138
|
*/
|
|
132
|
-
|
|
139
|
+
startContent?: ReactNode;
|
|
133
140
|
/**
|
|
134
|
-
* Custom
|
|
141
|
+
* Custom indicator for the expanded/collapsed state
|
|
142
|
+
* @default ChevronRight icon
|
|
143
|
+
*/
|
|
144
|
+
indicator?: ReactNode;
|
|
145
|
+
/**
|
|
146
|
+
* Custom appearance styles for all accordion item parts
|
|
135
147
|
*/
|
|
136
|
-
|
|
148
|
+
customAppearance?: AccordionItemCustomAppearance;
|
|
137
149
|
} & AccordionItemEvents;
|
|
138
150
|
|
|
139
151
|
declare const AccordionItem: React.FC<AccordionItemProps>;
|
package/dist/accordion/index.js
CHANGED
|
@@ -23,7 +23,10 @@ var useAccordionContext = () => {
|
|
|
23
23
|
|
|
24
24
|
// src/components/accordion/accordion.hook.ts
|
|
25
25
|
import { useState, useCallback, useMemo } from "react";
|
|
26
|
-
var useAccordionStyles = ({
|
|
26
|
+
var useAccordionStyles = ({
|
|
27
|
+
variant,
|
|
28
|
+
fullWidth
|
|
29
|
+
}) => {
|
|
27
30
|
const theme = useXUITheme();
|
|
28
31
|
const palette2 = useXUIPalette();
|
|
29
32
|
const containerStyles = useMemo(() => {
|
|
@@ -35,7 +38,7 @@ var useAccordionStyles = ({ variant, fullWidth }) => {
|
|
|
35
38
|
base.borderWidth = theme.borderWidth.md;
|
|
36
39
|
base.borderColor = theme.mode === "dark" ? palette2.gray[800] : theme.palette.gray[200];
|
|
37
40
|
base.borderRadius = theme.borderRadius.md;
|
|
38
|
-
base.
|
|
41
|
+
base.paddingHorizontal = theme.spacing.sm;
|
|
39
42
|
base.overflow = "hidden";
|
|
40
43
|
} else if (variant === "light") {
|
|
41
44
|
base.paddingHorizontal = theme.spacing.sm;
|
|
@@ -134,6 +137,7 @@ import {
|
|
|
134
137
|
Easing
|
|
135
138
|
} from "react-native";
|
|
136
139
|
import { colors as palette } from "@xaui/core/palette";
|
|
140
|
+
import { addOpacityToColor } from "@xaui/core";
|
|
137
141
|
var useAccordionItemState = (itemKey) => {
|
|
138
142
|
const context = useAccordionContext();
|
|
139
143
|
const resolvedItemKey = itemKey ?? "";
|
|
@@ -213,9 +217,9 @@ var useBaseStyles = (variant, isDisabled) => {
|
|
|
213
217
|
const base = { overflow: "hidden" };
|
|
214
218
|
if (variant === "splitted") {
|
|
215
219
|
base.paddingHorizontal = theme.spacing.md;
|
|
216
|
-
base.backgroundColor = theme.colors.default.background;
|
|
220
|
+
base.backgroundColor = addOpacityToColor(theme.colors.default.background, 0.5);
|
|
217
221
|
base.borderRadius = theme.borderRadius.md;
|
|
218
|
-
base.marginBottom = theme.spacing.
|
|
222
|
+
base.marginBottom = theme.spacing.xs;
|
|
219
223
|
} else if (variant === "bordered") {
|
|
220
224
|
base.paddingHorizontal = theme.spacing.md;
|
|
221
225
|
}
|
|
@@ -270,7 +274,7 @@ var useContentContainerStyle = (isCompact, variant) => {
|
|
|
270
274
|
const theme = useXUITheme();
|
|
271
275
|
const contentContainerStyle = useMemo2(
|
|
272
276
|
() => ({
|
|
273
|
-
paddingBottom: isCompact ? theme.spacing.
|
|
277
|
+
paddingBottom: isCompact ? theme.spacing.xs : theme.spacing.sm,
|
|
274
278
|
paddingHorizontal: variant === "light" ? theme.spacing.sm : 0
|
|
275
279
|
}),
|
|
276
280
|
[isCompact, variant, theme]
|
|
@@ -309,14 +313,7 @@ var AccordionItem = ({
|
|
|
309
313
|
subtitle,
|
|
310
314
|
startContent,
|
|
311
315
|
indicator,
|
|
312
|
-
|
|
313
|
-
headingStyle,
|
|
314
|
-
triggerStyle,
|
|
315
|
-
titleStyle,
|
|
316
|
-
subtitleStyle,
|
|
317
|
-
contentStyle,
|
|
318
|
-
startContentStyle,
|
|
319
|
-
indicatorStyle,
|
|
316
|
+
customAppearance,
|
|
320
317
|
onSelected
|
|
321
318
|
}) => {
|
|
322
319
|
const {
|
|
@@ -339,29 +336,36 @@ var AccordionItem = ({
|
|
|
339
336
|
const subtitleTextStyle = useSubtitleTextStyle();
|
|
340
337
|
const contentContainerStyle = useContentContainerStyle(isCompact, variant);
|
|
341
338
|
const foregroundColor = useForegroundColor();
|
|
342
|
-
return /* @__PURE__ */ React2.createElement(View, { style: [baseStyles,
|
|
339
|
+
return /* @__PURE__ */ React2.createElement(View, { style: [baseStyles, customAppearance?.base] }, /* @__PURE__ */ React2.createElement(View, { style: customAppearance?.heading }, /* @__PURE__ */ React2.createElement(
|
|
343
340
|
Pressable,
|
|
344
341
|
{
|
|
345
|
-
style: [triggerStyles,
|
|
342
|
+
style: [triggerStyles, customAppearance?.trigger],
|
|
346
343
|
onPress: handlePress,
|
|
347
344
|
disabled: isDisabled,
|
|
348
345
|
accessibilityRole: "button",
|
|
349
346
|
accessibilityState: { expanded: isExpanded, disabled: isDisabled }
|
|
350
347
|
},
|
|
351
|
-
startContent && /* @__PURE__ */ React2.createElement(View, { style: [styles.startContent,
|
|
352
|
-
/* @__PURE__ */ React2.createElement(View, { style: styles.titleWrapper }, typeof title === "string" ? /* @__PURE__ */ React2.createElement(Text, { style: [titleTextStyle,
|
|
348
|
+
startContent && /* @__PURE__ */ React2.createElement(View, { style: [styles.startContent, customAppearance?.startContent] }, startContent),
|
|
349
|
+
/* @__PURE__ */ React2.createElement(View, { style: styles.titleWrapper }, typeof title === "string" ? /* @__PURE__ */ React2.createElement(Text, { style: [titleTextStyle, customAppearance?.title] }, title) : title, subtitle && (typeof subtitle === "string" ? /* @__PURE__ */ React2.createElement(Text, { style: [subtitleTextStyle, customAppearance?.subtitle] }, subtitle) : subtitle)),
|
|
353
350
|
!hideIndicator && /* @__PURE__ */ React2.createElement(
|
|
354
351
|
Animated2.View,
|
|
355
352
|
{
|
|
356
353
|
style: [
|
|
357
354
|
styles.indicator,
|
|
358
|
-
|
|
355
|
+
customAppearance?.indicator,
|
|
359
356
|
{ transform: [{ rotate: rotationInterpolation }] }
|
|
360
357
|
]
|
|
361
358
|
},
|
|
362
359
|
indicator || /* @__PURE__ */ React2.createElement(ChevronRightIcon, { color: foregroundColor })
|
|
363
360
|
)
|
|
364
|
-
)), /* @__PURE__ */ React2.createElement(View, { style: styles.hiddenMeasure, pointerEvents: "none" }, /* @__PURE__ */ React2.createElement(
|
|
361
|
+
)), /* @__PURE__ */ React2.createElement(View, { style: styles.hiddenMeasure, pointerEvents: "none" }, /* @__PURE__ */ React2.createElement(
|
|
362
|
+
View,
|
|
363
|
+
{
|
|
364
|
+
onLayout: onContentLayout,
|
|
365
|
+
style: [contentContainerStyle, customAppearance?.content]
|
|
366
|
+
},
|
|
367
|
+
children
|
|
368
|
+
)), /* @__PURE__ */ React2.createElement(
|
|
365
369
|
Animated2.View,
|
|
366
370
|
{
|
|
367
371
|
style: [
|
|
@@ -369,7 +373,7 @@ var AccordionItem = ({
|
|
|
369
373
|
disableAnimation ? { height: isExpanded ? void 0 : 0 } : { height: heightInterpolation }
|
|
370
374
|
]
|
|
371
375
|
},
|
|
372
|
-
/* @__PURE__ */ React2.createElement(View, { style: [contentContainerStyle,
|
|
376
|
+
/* @__PURE__ */ React2.createElement(View, { style: [contentContainerStyle, customAppearance?.content] }, children)
|
|
373
377
|
));
|
|
374
378
|
};
|
|
375
379
|
AccordionItem.displayName = "AccordionItem";
|
|
@@ -408,8 +412,7 @@ var Accordion = (props) => {
|
|
|
408
412
|
variant = "light",
|
|
409
413
|
showDivider = false,
|
|
410
414
|
fullWidth = true,
|
|
411
|
-
|
|
412
|
-
itemStyle
|
|
415
|
+
customAppearance
|
|
413
416
|
} = props;
|
|
414
417
|
const { containerStyles, dividerColor } = useAccordionStyles({
|
|
415
418
|
variant,
|
|
@@ -418,14 +421,14 @@ var Accordion = (props) => {
|
|
|
418
421
|
const contextParams = buildAccordionContextParams(props);
|
|
419
422
|
const contextValue = useAccordionContextValue(contextParams);
|
|
420
423
|
const childrenArray = React4.Children.toArray(children);
|
|
421
|
-
return /* @__PURE__ */ React4.createElement(AccordionContext.Provider, { value: contextValue }, /* @__PURE__ */ React4.createElement(View2, { style: [containerStyles,
|
|
424
|
+
return /* @__PURE__ */ React4.createElement(AccordionContext.Provider, { value: contextValue }, /* @__PURE__ */ React4.createElement(View2, { style: [containerStyles, customAppearance?.container] }, childrenArray.map((child, index) => {
|
|
422
425
|
const isLast = index === childrenArray.length - 1;
|
|
423
426
|
const showBottomDivider = (showDivider || variant === "bordered") && !isLast && variant !== "splitted";
|
|
424
427
|
const resolvedChildKey = isAccordionItem(child) ? getItemKey(child.props.itemKey ?? normalizeElementKey(child.key), index) : getItemKey(
|
|
425
428
|
React4.isValidElement(child) ? normalizeElementKey(child.key) : void 0,
|
|
426
429
|
index
|
|
427
430
|
);
|
|
428
|
-
return /* @__PURE__ */ React4.createElement(View2, { key: resolvedChildKey, style:
|
|
431
|
+
return /* @__PURE__ */ React4.createElement(View2, { key: resolvedChildKey, style: customAppearance?.item }, isAccordionItem(child) ? React4.cloneElement(child, { itemKey: resolvedChildKey }) : child, showBottomDivider && /* @__PURE__ */ React4.createElement(Divider, { color: dividerColor, size: 2 }));
|
|
429
432
|
})));
|
|
430
433
|
};
|
|
431
434
|
export {
|