@platform-blocks/ui 0.4.0 → 0.5.0
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/lib/cjs/index.js +469 -169
- package/lib/cjs/index.js.map +1 -1
- package/lib/components/Avatar/Avatar.d.ts +1 -1
- package/lib/components/Avatar/types.d.ts +3 -3
- package/lib/components/Carousel/types.d.ts +18 -0
- package/lib/components/DataTable/DataTable.d.ts +1 -1
- package/lib/components/DataTable/types.d.ts +2 -0
- package/lib/components/Slider/types.d.ts +29 -1
- package/lib/esm/index.js +469 -169
- package/lib/esm/index.js.map +1 -1
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -12076,7 +12076,7 @@ function AppShellBase(props, ref) {
|
|
|
12076
12076
|
const breakpoint = useBreakpoint();
|
|
12077
12077
|
// Determine if mobile based on breakpoint and platform
|
|
12078
12078
|
const isMobile = reactNative.Platform.OS !== 'web' || breakpoint === 'xs' || breakpoint === 'sm';
|
|
12079
|
-
const headerConfig = layoutVisibility.header
|
|
12079
|
+
const headerConfig = layoutVisibility.header ? header : undefined;
|
|
12080
12080
|
const navbarConfig = layoutVisibility.navbar ? navbar : undefined;
|
|
12081
12081
|
const asideConfig = layoutVisibility.aside ? aside : undefined;
|
|
12082
12082
|
const footerConfig = layoutVisibility.footer ? footer : undefined;
|
|
@@ -17168,9 +17168,7 @@ const createInputStyles = (theme, isRTL = false) => {
|
|
|
17168
17168
|
? theme.colors.error[5]
|
|
17169
17169
|
: props.focused
|
|
17170
17170
|
? theme.colors.primary[5]
|
|
17171
|
-
:
|
|
17172
|
-
? theme.backgrounds.border
|
|
17173
|
-
: 'transparent',
|
|
17171
|
+
: theme.backgrounds.border,
|
|
17174
17172
|
// Optional focus shadow (web only) without affecting layout
|
|
17175
17173
|
...(props.focused && !props.disabled && typeof window !== 'undefined' && ((_a = theme.states) === null || _a === void 0 ? void 0 : _a.focusRing) && {
|
|
17176
17174
|
boxShadow: `0 0 0 2px ${theme.states.focusRing}`,
|
|
@@ -21067,105 +21065,116 @@ const useSliderGesture = (min, max, step, restrictToTicks, ticks, disabled) => {
|
|
|
21067
21065
|
}, [min, max, step, restrictToTicks, ticks]);
|
|
21068
21066
|
return { calculateNewValue };
|
|
21069
21067
|
};
|
|
21070
|
-
const SliderTrack = ({ disabled, theme, size, orientation, activeWidth = 0, activeLeft =
|
|
21068
|
+
const SliderTrack = ({ disabled, theme, size, orientation, activeWidth = 0, activeLeft, isRange = false, trackColor, activeTrackColor, trackStyle, activeTrackStyle, trackHeight, thumbSize, }) => {
|
|
21071
21069
|
const orientationProps = getOrientationProps(orientation);
|
|
21072
|
-
const
|
|
21073
|
-
const
|
|
21074
|
-
const
|
|
21070
|
+
const resolvedThumbSize = thumbSize !== null && thumbSize !== void 0 ? thumbSize : SLIDER_CONSTANTS.THUMB_SIZE[size];
|
|
21071
|
+
const resolvedTrackHeight = trackHeight !== null && trackHeight !== void 0 ? trackHeight : SLIDER_CONSTANTS.TRACK_HEIGHT[size];
|
|
21072
|
+
const resolvedActiveLeft = activeLeft !== null && activeLeft !== void 0 ? activeLeft : (resolvedThumbSize / 2);
|
|
21073
|
+
const inactiveTrackBaseStyle = {
|
|
21075
21074
|
position: 'absolute',
|
|
21076
|
-
backgroundColor: disabled ? theme.colors.gray[2] : theme.colors.gray[3],
|
|
21077
|
-
borderRadius:
|
|
21075
|
+
backgroundColor: disabled && !trackColor ? theme.colors.gray[2] : (trackColor !== null && trackColor !== void 0 ? trackColor : theme.colors.gray[3]),
|
|
21076
|
+
borderRadius: resolvedTrackHeight / 2,
|
|
21078
21077
|
};
|
|
21079
|
-
const
|
|
21078
|
+
const activeTrackBaseStyle = {
|
|
21080
21079
|
position: 'absolute',
|
|
21081
|
-
backgroundColor: disabled ? theme.colors.gray[4] : theme.colors.primary[5],
|
|
21082
|
-
borderRadius:
|
|
21080
|
+
backgroundColor: disabled && !activeTrackColor ? theme.colors.gray[4] : (activeTrackColor !== null && activeTrackColor !== void 0 ? activeTrackColor : theme.colors.primary[5]),
|
|
21081
|
+
borderRadius: resolvedTrackHeight / 2,
|
|
21083
21082
|
};
|
|
21084
21083
|
if (orientationProps.isVertical) {
|
|
21085
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactNative.View, { style:
|
|
21086
|
-
|
|
21087
|
-
|
|
21088
|
-
|
|
21089
|
-
|
|
21090
|
-
|
|
21091
|
-
|
|
21092
|
-
|
|
21093
|
-
|
|
21094
|
-
|
|
21095
|
-
|
|
21096
|
-
|
|
21097
|
-
|
|
21098
|
-
|
|
21099
|
-
|
|
21100
|
-
|
|
21101
|
-
|
|
21102
|
-
|
|
21103
|
-
|
|
21104
|
-
|
|
21105
|
-
|
|
21106
|
-
|
|
21107
|
-
|
|
21108
|
-
|
|
21109
|
-
|
|
21110
|
-
|
|
21111
|
-
|
|
21112
|
-
|
|
21113
|
-
|
|
21114
|
-
|
|
21115
|
-
|
|
21116
|
-
|
|
21117
|
-
|
|
21118
|
-
|
|
21119
|
-
|
|
21084
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactNative.View, { style: [
|
|
21085
|
+
{
|
|
21086
|
+
...inactiveTrackBaseStyle,
|
|
21087
|
+
top: resolvedThumbSize / 2,
|
|
21088
|
+
bottom: resolvedThumbSize / 2,
|
|
21089
|
+
width: resolvedTrackHeight,
|
|
21090
|
+
left: (resolvedThumbSize - resolvedTrackHeight) / 2,
|
|
21091
|
+
},
|
|
21092
|
+
trackStyle,
|
|
21093
|
+
] }), activeWidth > 0 && (jsxRuntime.jsx(reactNative.View, { style: [
|
|
21094
|
+
{
|
|
21095
|
+
...activeTrackBaseStyle,
|
|
21096
|
+
...(isRange ? {
|
|
21097
|
+
top: activeLeft !== null && activeLeft !== void 0 ? activeLeft : resolvedActiveLeft,
|
|
21098
|
+
height: activeWidth,
|
|
21099
|
+
} : {
|
|
21100
|
+
bottom: resolvedThumbSize / 2,
|
|
21101
|
+
height: activeWidth,
|
|
21102
|
+
}),
|
|
21103
|
+
width: resolvedTrackHeight,
|
|
21104
|
+
left: (resolvedThumbSize - resolvedTrackHeight) / 2,
|
|
21105
|
+
},
|
|
21106
|
+
activeTrackStyle,
|
|
21107
|
+
] }))] }));
|
|
21108
|
+
}
|
|
21109
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactNative.View, { style: [
|
|
21110
|
+
{
|
|
21111
|
+
...inactiveTrackBaseStyle,
|
|
21112
|
+
left: resolvedThumbSize / 2,
|
|
21113
|
+
right: resolvedThumbSize / 2,
|
|
21114
|
+
height: resolvedTrackHeight,
|
|
21115
|
+
top: (SLIDER_CONSTANTS.CONTAINER_HEIGHT - resolvedTrackHeight) / 2,
|
|
21116
|
+
},
|
|
21117
|
+
trackStyle,
|
|
21118
|
+
] }), activeWidth > 0 && (jsxRuntime.jsx(reactNative.View, { style: [
|
|
21119
|
+
{
|
|
21120
|
+
...activeTrackBaseStyle,
|
|
21121
|
+
left: activeLeft !== null && activeLeft !== void 0 ? activeLeft : resolvedActiveLeft,
|
|
21122
|
+
width: activeWidth,
|
|
21123
|
+
height: resolvedTrackHeight,
|
|
21124
|
+
top: (SLIDER_CONSTANTS.CONTAINER_HEIGHT - resolvedTrackHeight) / 2,
|
|
21125
|
+
},
|
|
21126
|
+
activeTrackStyle,
|
|
21127
|
+
] }))] }));
|
|
21128
|
+
};
|
|
21129
|
+
const SliderTicks = ({ ticks, disabled, theme, size, orientation, keyPrefix = 'tick', trackHeight, thumbSize, activeTickColor, tickColor, }) => {
|
|
21120
21130
|
const orientationProps = getOrientationProps(orientation);
|
|
21121
|
-
const
|
|
21122
|
-
const
|
|
21131
|
+
const resolvedThumbSize = thumbSize !== null && thumbSize !== void 0 ? thumbSize : SLIDER_CONSTANTS.THUMB_SIZE[size];
|
|
21132
|
+
const resolvedTrackHeight = trackHeight !== null && trackHeight !== void 0 ? trackHeight : SLIDER_CONSTANTS.TRACK_HEIGHT[size];
|
|
21133
|
+
const inactiveColor = disabled && !tickColor ? theme.colors.gray[2] : (tickColor !== null && tickColor !== void 0 ? tickColor : theme.colors.gray[4]);
|
|
21134
|
+
const activeColor = disabled && !activeTickColor ? theme.colors.gray[4] : (activeTickColor !== null && activeTickColor !== void 0 ? activeTickColor : theme.colors.primary[5]);
|
|
21123
21135
|
if (orientationProps.isVertical) {
|
|
21124
21136
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [ticks.map((tick, index) => (jsxRuntime.jsx(reactNative.View, { style: {
|
|
21125
21137
|
position: 'absolute',
|
|
21126
|
-
top:
|
|
21127
|
-
left: (
|
|
21138
|
+
top: resolvedThumbSize / 2 + tick.position,
|
|
21139
|
+
left: (resolvedThumbSize - resolvedTrackHeight) / 2 - 3,
|
|
21128
21140
|
height: 2,
|
|
21129
|
-
width:
|
|
21130
|
-
backgroundColor: tick.isActive
|
|
21131
|
-
? (disabled ? theme.colors.gray[4] : theme.colors.primary[5])
|
|
21132
|
-
: (disabled ? theme.colors.gray[2] : theme.colors.gray[4]),
|
|
21141
|
+
width: resolvedTrackHeight + 6,
|
|
21142
|
+
backgroundColor: tick.isActive ? activeColor : inactiveColor,
|
|
21133
21143
|
borderRadius: 1,
|
|
21134
21144
|
} }, `${keyPrefix}-${tick.value}-${index}`))), ticks.map((tick, index) => (tick.label ? (jsxRuntime.jsx(reactNative.View, { style: {
|
|
21135
21145
|
position: 'absolute',
|
|
21136
|
-
top:
|
|
21137
|
-
left:
|
|
21146
|
+
top: resolvedThumbSize / 2 + tick.position - 10,
|
|
21147
|
+
left: resolvedThumbSize + 8,
|
|
21138
21148
|
height: 20,
|
|
21139
21149
|
justifyContent: 'center',
|
|
21140
21150
|
}, children: jsxRuntime.jsx(Text, { size: "xs", children: tick.label }) }, `${keyPrefix}-label-${tick.value}-${index}`)) : null))] }));
|
|
21141
21151
|
}
|
|
21142
21152
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [ticks.map((tick, index) => (jsxRuntime.jsx(reactNative.View, { style: {
|
|
21143
21153
|
position: 'absolute',
|
|
21144
|
-
left:
|
|
21145
|
-
top: (SLIDER_CONSTANTS.CONTAINER_HEIGHT -
|
|
21154
|
+
left: resolvedThumbSize / 2 + tick.position,
|
|
21155
|
+
top: (SLIDER_CONSTANTS.CONTAINER_HEIGHT - resolvedTrackHeight) / 2 - 3,
|
|
21146
21156
|
width: 2,
|
|
21147
|
-
height:
|
|
21148
|
-
backgroundColor: tick.isActive
|
|
21149
|
-
? (disabled ? theme.colors.gray[4] : theme.colors.primary[5])
|
|
21150
|
-
: (disabled ? theme.colors.gray[2] : theme.colors.gray[4]),
|
|
21157
|
+
height: resolvedTrackHeight + 6,
|
|
21158
|
+
backgroundColor: tick.isActive ? activeColor : inactiveColor,
|
|
21151
21159
|
borderRadius: 1,
|
|
21152
21160
|
} }, `${keyPrefix}-${tick.value}-${index}`))), ticks.map((tick, index) => (tick.label ? (jsxRuntime.jsx(reactNative.View, { style: {
|
|
21153
21161
|
position: 'absolute',
|
|
21154
|
-
left:
|
|
21162
|
+
left: resolvedThumbSize / 2 + tick.position - 20,
|
|
21155
21163
|
top: SLIDER_CONSTANTS.CONTAINER_HEIGHT + 8,
|
|
21156
21164
|
width: 40,
|
|
21157
21165
|
alignItems: 'center',
|
|
21158
21166
|
}, children: jsxRuntime.jsx(Text, { size: "xs", style: { textAlign: 'center' }, children: tick.label }) }, `${keyPrefix}-label-${tick.value}-${index}`)) : null))] }));
|
|
21159
21167
|
};
|
|
21160
|
-
const SliderThumb = ({ position, disabled, theme, size, orientation, isDragging, zIndex = 1, panHandlers }) => {
|
|
21168
|
+
const SliderThumb = ({ position, disabled, theme, size, orientation, isDragging, zIndex = 1, panHandlers, thumbColor, thumbStyle, thumbSize, }) => {
|
|
21161
21169
|
const orientationProps = getOrientationProps(orientation);
|
|
21162
|
-
const
|
|
21170
|
+
const resolvedThumbSize = thumbSize !== null && thumbSize !== void 0 ? thumbSize : SLIDER_CONSTANTS.THUMB_SIZE[size];
|
|
21171
|
+
const resolvedThumbColor = disabled && !thumbColor ? theme.colors.gray[4] : (thumbColor !== null && thumbColor !== void 0 ? thumbColor : theme.colors.primary[5]);
|
|
21163
21172
|
const baseStyle = {
|
|
21164
21173
|
position: 'absolute',
|
|
21165
|
-
width:
|
|
21166
|
-
height:
|
|
21167
|
-
backgroundColor:
|
|
21168
|
-
borderRadius:
|
|
21174
|
+
width: resolvedThumbSize,
|
|
21175
|
+
height: resolvedThumbSize,
|
|
21176
|
+
backgroundColor: resolvedThumbColor,
|
|
21177
|
+
borderRadius: resolvedThumbSize / 2,
|
|
21169
21178
|
borderWidth: 2,
|
|
21170
21179
|
borderColor: 'white',
|
|
21171
21180
|
boxShadow: '0 2px 4px rgba(0, 0, 0, 0.2)',
|
|
@@ -21174,36 +21183,43 @@ const SliderThumb = ({ position, disabled, theme, size, orientation, isDragging,
|
|
|
21174
21183
|
zIndex,
|
|
21175
21184
|
};
|
|
21176
21185
|
if (orientationProps.isVertical) {
|
|
21177
|
-
return (jsxRuntime.jsx(reactNative.View, { style:
|
|
21178
|
-
|
|
21179
|
-
|
|
21180
|
-
|
|
21181
|
-
|
|
21186
|
+
return (jsxRuntime.jsx(reactNative.View, { style: [
|
|
21187
|
+
baseStyle,
|
|
21188
|
+
{
|
|
21189
|
+
top: position,
|
|
21190
|
+
left: 0,
|
|
21191
|
+
},
|
|
21192
|
+
thumbStyle,
|
|
21193
|
+
], ...panHandlers }));
|
|
21182
21194
|
}
|
|
21183
|
-
return (jsxRuntime.jsx(reactNative.View, { style:
|
|
21184
|
-
|
|
21185
|
-
|
|
21186
|
-
|
|
21187
|
-
|
|
21195
|
+
return (jsxRuntime.jsx(reactNative.View, { style: [
|
|
21196
|
+
baseStyle,
|
|
21197
|
+
{
|
|
21198
|
+
left: position,
|
|
21199
|
+
top: (SLIDER_CONSTANTS.CONTAINER_HEIGHT - resolvedThumbSize) / 2,
|
|
21200
|
+
},
|
|
21201
|
+
thumbStyle,
|
|
21202
|
+
], ...panHandlers }));
|
|
21188
21203
|
};
|
|
21189
21204
|
const SliderLabel = ({ label }) => (jsxRuntime.jsx(reactNative.View, { style: { marginBottom: 8 }, children: typeof label === 'string' ? (jsxRuntime.jsx(Text, { size: "sm", weight: "medium", children: label })) : (label) }));
|
|
21190
|
-
const SliderValueLabel = ({ value, position, size, orientation, isCard = false }) => {
|
|
21205
|
+
const SliderValueLabel = ({ value, position, size, orientation, isCard = false, thumbSize, }) => {
|
|
21191
21206
|
const orientationProps = getOrientationProps(orientation);
|
|
21192
|
-
const
|
|
21207
|
+
const resolvedThumbSize = thumbSize !== null && thumbSize !== void 0 ? thumbSize : SLIDER_CONSTANTS.THUMB_SIZE[size];
|
|
21193
21208
|
// round number to 2 decimal places for display
|
|
21194
21209
|
const displayValue = typeof value === 'number' ? value.toFixed(2) : value;
|
|
21195
21210
|
if (orientationProps.isVertical) {
|
|
21211
|
+
const verticalLabelOffset = resolvedThumbSize + 16; // keep label clear of the thumb
|
|
21196
21212
|
return (jsxRuntime.jsx(reactNative.View, { style: {
|
|
21197
21213
|
position: 'absolute',
|
|
21198
|
-
top: position + (
|
|
21199
|
-
right:
|
|
21214
|
+
top: position + (resolvedThumbSize / 2) - 10,
|
|
21215
|
+
right: verticalLabelOffset,
|
|
21200
21216
|
height: 20,
|
|
21201
21217
|
justifyContent: 'center',
|
|
21202
21218
|
}, children: isCard ? (jsxRuntime.jsx(Card, { p: "xs", variant: "filled", children: jsxRuntime.jsx(Text, { size: "sm", children: displayValue }) })) : (jsxRuntime.jsx(Text, { size: "sm", children: displayValue })) }));
|
|
21203
21219
|
}
|
|
21204
21220
|
return (jsxRuntime.jsx(reactNative.View, { style: {
|
|
21205
21221
|
position: 'absolute',
|
|
21206
|
-
left: position + (
|
|
21222
|
+
left: position + (resolvedThumbSize / 2) - 50,
|
|
21207
21223
|
bottom: SLIDER_CONSTANTS.CONTAINER_HEIGHT - 6, // Moved closer to thumb
|
|
21208
21224
|
width: 100,
|
|
21209
21225
|
alignItems: 'center',
|
|
@@ -21219,9 +21235,34 @@ const SLIDER_SIZE_SCALE = {
|
|
|
21219
21235
|
'2xl': 'lg',
|
|
21220
21236
|
'3xl': 'lg',
|
|
21221
21237
|
};
|
|
21238
|
+
const resolvePaletteColor = (themeColors, scheme) => {
|
|
21239
|
+
if (!scheme || typeof scheme !== 'string') {
|
|
21240
|
+
return undefined;
|
|
21241
|
+
}
|
|
21242
|
+
const palette = themeColors[scheme];
|
|
21243
|
+
if (Array.isArray(palette)) {
|
|
21244
|
+
return palette;
|
|
21245
|
+
}
|
|
21246
|
+
return undefined;
|
|
21247
|
+
};
|
|
21248
|
+
const resolveSliderColors = (theme, { colorScheme, trackColor, activeTrackColor, thumbColor, tickColor, activeTickColor, }) => {
|
|
21249
|
+
var _a, _b;
|
|
21250
|
+
const palette = resolvePaletteColor(theme.colors, colorScheme);
|
|
21251
|
+
const schemeColor = (_b = (_a = palette === null || palette === void 0 ? void 0 : palette[5]) !== null && _a !== void 0 ? _a : (typeof colorScheme === 'string' ? colorScheme : undefined)) !== null && _b !== void 0 ? _b : theme.colors.primary[5];
|
|
21252
|
+
const resolvedActiveTrack = activeTrackColor !== null && activeTrackColor !== void 0 ? activeTrackColor : schemeColor;
|
|
21253
|
+
const defaultTrackColor = theme.colorScheme === 'dark' ? theme.colors.gray[6] : theme.colors.gray[3];
|
|
21254
|
+
const defaultTickColor = theme.colorScheme === 'dark' ? theme.colors.gray[5] : theme.colors.gray[4];
|
|
21255
|
+
return {
|
|
21256
|
+
trackColor: trackColor !== null && trackColor !== void 0 ? trackColor : defaultTrackColor,
|
|
21257
|
+
activeTrackColor: resolvedActiveTrack,
|
|
21258
|
+
thumbColor: thumbColor !== null && thumbColor !== void 0 ? thumbColor : resolvedActiveTrack,
|
|
21259
|
+
tickColor: tickColor !== null && tickColor !== void 0 ? tickColor : defaultTickColor,
|
|
21260
|
+
activeTickColor: activeTickColor !== null && activeTickColor !== void 0 ? activeTickColor : resolvedActiveTrack,
|
|
21261
|
+
};
|
|
21262
|
+
};
|
|
21222
21263
|
// Optimized Single Slider Component
|
|
21223
21264
|
const Slider = factory((props, ref) => {
|
|
21224
|
-
const { value, defaultValue = 0, onChange, min = 0, max = 100, step = 1, disabled = false, size = 'md', orientation = 'horizontal', containerSize, fullWidth = true, label, valueLabel, valueLabelAlwaysOn = false, ticks, showTicks = false, restrictToTicks = false, style, ...spacingProps } = props;
|
|
21265
|
+
const { value, defaultValue = 0, onChange, min = 0, max = 100, step = 1, disabled = false, size = 'md', orientation = 'horizontal', containerSize, fullWidth = true, label, valueLabel, valueLabelAlwaysOn = false, ticks, showTicks = false, restrictToTicks = false, trackColor, activeTrackColor, thumbColor, trackSize, thumbSize: thumbSizeProp, colorScheme = 'primary', trackStyle, activeTrackStyle, thumbStyle, tickColor, activeTickColor, style, ...spacingProps } = props;
|
|
21225
21266
|
const theme = useTheme();
|
|
21226
21267
|
const [isDragging, setIsDragging] = React.useState(false);
|
|
21227
21268
|
// Uncontrolled internal value
|
|
@@ -21250,14 +21291,31 @@ const Slider = factory((props, ref) => {
|
|
|
21250
21291
|
: 'md'
|
|
21251
21292
|
: (resolvedSliderSize !== null && resolvedSliderSize !== void 0 ? resolvedSliderSize : 'md');
|
|
21252
21293
|
const orientationProps = getOrientationProps(orientation, containerSize);
|
|
21253
|
-
const thumbSize = SLIDER_CONSTANTS.THUMB_SIZE[sliderSize];
|
|
21294
|
+
const thumbSize = thumbSizeProp !== null && thumbSizeProp !== void 0 ? thumbSizeProp : SLIDER_CONSTANTS.THUMB_SIZE[sliderSize];
|
|
21295
|
+
const trackHeight = trackSize !== null && trackSize !== void 0 ? trackSize : SLIDER_CONSTANTS.TRACK_HEIGHT[sliderSize];
|
|
21254
21296
|
// Memoized processed value
|
|
21255
21297
|
const clampedValue = useSliderValue(isControlled ? value : internal, min, max, step, restrictToTicks, ticks, false);
|
|
21256
21298
|
// Memoized value label handling
|
|
21299
|
+
const defaultValueFormatter = React.useCallback((val) => Math.round(val).toString(), []);
|
|
21300
|
+
const resolvedValueLabel = React.useMemo(() => {
|
|
21301
|
+
if (valueLabel === null)
|
|
21302
|
+
return null;
|
|
21303
|
+
if (valueLabel)
|
|
21304
|
+
return valueLabel;
|
|
21305
|
+
return defaultValueFormatter;
|
|
21306
|
+
}, [valueLabel, defaultValueFormatter]);
|
|
21257
21307
|
const labelConfig = React.useMemo(() => ({
|
|
21258
|
-
shouldShow:
|
|
21259
|
-
formatter:
|
|
21260
|
-
}), [
|
|
21308
|
+
shouldShow: !!resolvedValueLabel && (valueLabelAlwaysOn || isDragging || (reactNative.Platform.OS === 'web' && isHovering)),
|
|
21309
|
+
formatter: resolvedValueLabel !== null && resolvedValueLabel !== void 0 ? resolvedValueLabel : defaultValueFormatter,
|
|
21310
|
+
}), [resolvedValueLabel, valueLabelAlwaysOn, isDragging, isHovering, defaultValueFormatter]);
|
|
21311
|
+
const sliderColors = React.useMemo(() => resolveSliderColors(theme, {
|
|
21312
|
+
colorScheme,
|
|
21313
|
+
trackColor,
|
|
21314
|
+
activeTrackColor,
|
|
21315
|
+
thumbColor,
|
|
21316
|
+
tickColor,
|
|
21317
|
+
activeTickColor,
|
|
21318
|
+
}), [theme, colorScheme, trackColor, activeTrackColor, thumbColor, tickColor, activeTickColor]);
|
|
21261
21319
|
// Memoized position calculations
|
|
21262
21320
|
const positions = React.useMemo(() => {
|
|
21263
21321
|
var _a, _b;
|
|
@@ -21387,6 +21445,7 @@ const Slider = factory((props, ref) => {
|
|
|
21387
21445
|
height: fullWidth && orientation === 'vertical' ? '100%' : orientationProps.containerHeight,
|
|
21388
21446
|
justifyContent: 'center',
|
|
21389
21447
|
position: 'relative',
|
|
21448
|
+
...(reactNative.Platform.OS === 'web' && orientation === 'vertical' ? { touchAction: 'none' } : null),
|
|
21390
21449
|
}, onLayout: (event) => {
|
|
21391
21450
|
// When fullWidth is enabled, track the actual container dimensions
|
|
21392
21451
|
if (fullWidth) {
|
|
@@ -21400,11 +21459,11 @@ const Slider = factory((props, ref) => {
|
|
|
21400
21459
|
}, onStartShouldSetResponder: () => !isDragging, onResponderGrant: handlePress, ...(reactNative.Platform.OS === 'web' && {
|
|
21401
21460
|
onMouseEnter: () => setIsHovering(true),
|
|
21402
21461
|
onMouseLeave: () => setIsHovering(false),
|
|
21403
|
-
}), ...panResponder.panHandlers, children: [jsxRuntime.jsx(SliderTrack, { disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, activeWidth: positions.activeLength }), jsxRuntime.jsx(SliderTicks, { ticks: allTicks, disabled: disabled, theme: theme, size: sliderSize, orientation: orientation }), jsxRuntime.jsx(SliderThumb, { position: positions.thumbPosition, disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, isDragging: isDragging }), labelConfig.shouldShow && (jsxRuntime.jsx(SliderValueLabel, { value: labelConfig.formatter(clampedValue), position: positions.thumbPosition, size: sliderSize, orientation: orientation, isCard: true }))] })] }));
|
|
21462
|
+
}), ...panResponder.panHandlers, children: [jsxRuntime.jsx(SliderTrack, { disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, activeWidth: positions.activeLength, trackColor: sliderColors.trackColor, activeTrackColor: sliderColors.activeTrackColor, trackStyle: trackStyle, activeTrackStyle: activeTrackStyle, trackHeight: trackHeight, thumbSize: thumbSize }), jsxRuntime.jsx(SliderTicks, { ticks: allTicks, disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, trackHeight: trackHeight, thumbSize: thumbSize, tickColor: sliderColors.tickColor, activeTickColor: sliderColors.activeTickColor }), jsxRuntime.jsx(SliderThumb, { position: positions.thumbPosition, disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, isDragging: isDragging, thumbColor: sliderColors.thumbColor, thumbStyle: thumbStyle, thumbSize: thumbSize }), labelConfig.shouldShow && (jsxRuntime.jsx(SliderValueLabel, { value: labelConfig.formatter(clampedValue), position: positions.thumbPosition, size: sliderSize, orientation: orientation, isCard: true, thumbSize: thumbSize }))] })] }));
|
|
21404
21463
|
});
|
|
21405
21464
|
// Optimized Range Slider Component
|
|
21406
21465
|
const RangeSlider = factory((props, ref) => {
|
|
21407
|
-
const { value = [0, 100], onChange, min = 0, max = 100, step = 1, disabled = false, size = 'md', orientation = 'horizontal', containerSize, fullWidth = true, label, valueLabel, valueLabelAlwaysOn = false, ticks, showTicks = false, restrictToTicks = false, pushOnOverlap = true, style, ...spacingProps } = props;
|
|
21466
|
+
const { value = [0, 100], onChange, min = 0, max = 100, step = 1, disabled = false, size = 'md', orientation = 'horizontal', containerSize, fullWidth = true, label, valueLabel, valueLabelAlwaysOn = false, ticks, showTicks = false, restrictToTicks = false, pushOnOverlap = true, trackColor, activeTrackColor, thumbColor, trackSize, thumbSize: thumbSizeProp, colorScheme = 'primary', trackStyle, activeTrackStyle, thumbStyle, tickColor, activeTickColor, style, ...spacingProps } = props;
|
|
21408
21467
|
const theme = useTheme();
|
|
21409
21468
|
const [dragState, setDragState] = React.useState({ thumb: null });
|
|
21410
21469
|
const [isHovering, setIsHovering] = React.useState(false);
|
|
@@ -21424,8 +21483,17 @@ const RangeSlider = factory((props, ref) => {
|
|
|
21424
21483
|
: 'md'
|
|
21425
21484
|
: (rangeResolvedSliderSize !== null && rangeResolvedSliderSize !== void 0 ? rangeResolvedSliderSize : 'md');
|
|
21426
21485
|
const orientationProps = getOrientationProps(orientation, containerSize);
|
|
21427
|
-
const thumbSize = SLIDER_CONSTANTS.THUMB_SIZE[sliderSize];
|
|
21486
|
+
const thumbSize = thumbSizeProp !== null && thumbSizeProp !== void 0 ? thumbSizeProp : SLIDER_CONSTANTS.THUMB_SIZE[sliderSize];
|
|
21487
|
+
const trackHeight = trackSize !== null && trackSize !== void 0 ? trackSize : SLIDER_CONSTANTS.TRACK_HEIGHT[sliderSize];
|
|
21428
21488
|
React.useRef(null);
|
|
21489
|
+
const sliderColors = React.useMemo(() => resolveSliderColors(theme, {
|
|
21490
|
+
colorScheme,
|
|
21491
|
+
trackColor,
|
|
21492
|
+
activeTrackColor,
|
|
21493
|
+
thumbColor,
|
|
21494
|
+
tickColor,
|
|
21495
|
+
activeTickColor,
|
|
21496
|
+
}), [theme, colorScheme, trackColor, activeTrackColor, thumbColor, tickColor, activeTickColor]);
|
|
21429
21497
|
// Memoized processed values
|
|
21430
21498
|
const [minValue, maxValue] = useSliderValue(value, min, max, step, restrictToTicks, ticks, true);
|
|
21431
21499
|
// Memoized backward compatibility handling
|
|
@@ -21661,6 +21729,7 @@ const RangeSlider = factory((props, ref) => {
|
|
|
21661
21729
|
height: fullWidth && orientation === 'vertical' ? '100%' : orientationProps.containerHeight,
|
|
21662
21730
|
justifyContent: 'center',
|
|
21663
21731
|
position: 'relative',
|
|
21732
|
+
...(reactNative.Platform.OS === 'web' && orientation === 'vertical' ? { touchAction: 'none' } : null),
|
|
21664
21733
|
}, onLayout: (event) => {
|
|
21665
21734
|
// When fullWidth is enabled, track the actual container dimensions
|
|
21666
21735
|
if (fullWidth) {
|
|
@@ -21674,7 +21743,7 @@ const RangeSlider = factory((props, ref) => {
|
|
|
21674
21743
|
}, onStartShouldSetResponder: () => true, onResponderGrant: handleTrackPress, ...(reactNative.Platform.OS === 'web' && {
|
|
21675
21744
|
onMouseEnter: () => setIsHovering(true),
|
|
21676
21745
|
onMouseLeave: () => setIsHovering(false),
|
|
21677
|
-
}), collapsable: false, children: [jsxRuntime.jsx(SliderTrack, { disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, activeWidth: positions.activeWidth, activeLeft: positions.activeLeft, isRange: true }), jsxRuntime.jsx(SliderTicks, { ticks: allTicks, disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, keyPrefix: "range-tick" }), jsxRuntime.jsx(SliderThumb, { position: positions.minThumbPosition, disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, isDragging: dragState.thumb === 'min', zIndex: dragState.thumb === 'min' ? 10 : 1, panHandlers: minThumbPanResponder.panHandlers }), jsxRuntime.jsx(SliderThumb, { position: positions.maxThumbPosition, disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, isDragging: dragState.thumb === 'max', zIndex: dragState.thumb === 'max' ? 10 : 2, panHandlers: maxThumbPanResponder.panHandlers }), labelConfig.shouldShow && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(SliderValueLabel, { value: labelConfig.formatter(minValue, 0), position: positions.minThumbPosition, size: sliderSize, orientation: orientation, isCard: true }), jsxRuntime.jsx(SliderValueLabel, { value: labelConfig.formatter(maxValue, 1), position: positions.maxThumbPosition, size: sliderSize, orientation: orientation, isCard: true })] }))] })] }));
|
|
21746
|
+
}), collapsable: false, children: [jsxRuntime.jsx(SliderTrack, { disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, activeWidth: positions.activeWidth, activeLeft: positions.activeLeft, isRange: true, trackColor: sliderColors.trackColor, activeTrackColor: sliderColors.activeTrackColor, trackStyle: trackStyle, activeTrackStyle: activeTrackStyle, trackHeight: trackHeight, thumbSize: thumbSize }), jsxRuntime.jsx(SliderTicks, { ticks: allTicks, disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, keyPrefix: "range-tick", trackHeight: trackHeight, thumbSize: thumbSize, tickColor: sliderColors.tickColor, activeTickColor: sliderColors.activeTickColor }), jsxRuntime.jsx(SliderThumb, { position: positions.minThumbPosition, disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, isDragging: dragState.thumb === 'min', zIndex: dragState.thumb === 'min' ? 10 : 1, panHandlers: minThumbPanResponder.panHandlers, thumbColor: sliderColors.thumbColor, thumbStyle: thumbStyle, thumbSize: thumbSize }), jsxRuntime.jsx(SliderThumb, { position: positions.maxThumbPosition, disabled: disabled, theme: theme, size: sliderSize, orientation: orientation, isDragging: dragState.thumb === 'max', zIndex: dragState.thumb === 'max' ? 10 : 2, panHandlers: maxThumbPanResponder.panHandlers, thumbColor: sliderColors.thumbColor, thumbStyle: thumbStyle, thumbSize: thumbSize }), labelConfig.shouldShow && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(SliderValueLabel, { value: labelConfig.formatter(minValue, 0), position: positions.minThumbPosition, size: sliderSize, orientation: orientation, isCard: true, thumbSize: thumbSize }), jsxRuntime.jsx(SliderValueLabel, { value: labelConfig.formatter(maxValue, 1), position: positions.maxThumbPosition, size: sliderSize, orientation: orientation, isCard: true, thumbSize: thumbSize })] }))] })] }));
|
|
21678
21747
|
});
|
|
21679
21748
|
|
|
21680
21749
|
const clampNumber$1 = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
@@ -31568,13 +31637,13 @@ function Indicator({ size = 'sm', color, borderColor, borderWidth = 1, placement
|
|
|
31568
31637
|
|
|
31569
31638
|
const AVATAR_ALLOWED_SIZES = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'];
|
|
31570
31639
|
const AVATAR_SIZE_SCALE = {
|
|
31571
|
-
xs: { avatar: 24,
|
|
31572
|
-
sm: { avatar: 32,
|
|
31573
|
-
md: { avatar: 40,
|
|
31574
|
-
lg: { avatar: 48,
|
|
31575
|
-
xl: { avatar: 64,
|
|
31576
|
-
'2xl': { avatar: 80,
|
|
31577
|
-
'3xl': { avatar: 96,
|
|
31640
|
+
xs: { avatar: 24, indicator: 6, text: 'xs' },
|
|
31641
|
+
sm: { avatar: 32, indicator: 8, text: 'xs' },
|
|
31642
|
+
md: { avatar: 40, indicator: 10, text: 'sm' },
|
|
31643
|
+
lg: { avatar: 48, indicator: 12, text: 'md' },
|
|
31644
|
+
xl: { avatar: 64, indicator: 16, text: 'lg' },
|
|
31645
|
+
'2xl': { avatar: 80, indicator: 20, text: 'xl' },
|
|
31646
|
+
'3xl': { avatar: 96, indicator: 24, text: '2xl' },
|
|
31578
31647
|
};
|
|
31579
31648
|
const BASE_AVATAR_METRICS = AVATAR_SIZE_SCALE.md;
|
|
31580
31649
|
function resolveAvatarMetrics(value) {
|
|
@@ -31592,11 +31661,11 @@ function resolveAvatarMetrics(value) {
|
|
|
31592
31661
|
}
|
|
31593
31662
|
function calculateNumericMetrics$1(value) {
|
|
31594
31663
|
const ratio = value / BASE_AVATAR_METRICS.avatar;
|
|
31595
|
-
const
|
|
31664
|
+
const indicator = Math.max(4, Math.round(BASE_AVATAR_METRICS.indicator * ratio));
|
|
31596
31665
|
const text = pickTextSize(value);
|
|
31597
31666
|
return {
|
|
31598
31667
|
avatar: value,
|
|
31599
|
-
|
|
31668
|
+
indicator,
|
|
31600
31669
|
text,
|
|
31601
31670
|
};
|
|
31602
31671
|
}
|
|
@@ -31615,9 +31684,9 @@ function pickTextSize(value) {
|
|
|
31615
31684
|
return 'sm';
|
|
31616
31685
|
return 'xs';
|
|
31617
31686
|
}
|
|
31618
|
-
function Avatar({ size = 'md', src, fallback, backgroundColor, textColor = 'white', online,
|
|
31687
|
+
function Avatar({ size = 'md', src, fallback, backgroundColor, textColor = 'white', online, indicatorColor, style, accessibilityLabel, label, description, gap = 8, showText = true, }) {
|
|
31619
31688
|
const theme = useTheme();
|
|
31620
|
-
const { avatar: avatarSize,
|
|
31689
|
+
const { avatar: avatarSize, indicator: indicatorSize, text: textSize } = resolveAvatarMetrics(size);
|
|
31621
31690
|
const avatarStyle = {
|
|
31622
31691
|
width: avatarSize,
|
|
31623
31692
|
height: avatarSize,
|
|
@@ -31635,7 +31704,7 @@ function Avatar({ size = 'md', src, fallback, backgroundColor, textColor = 'whit
|
|
|
31635
31704
|
width: avatarSize,
|
|
31636
31705
|
height: avatarSize,
|
|
31637
31706
|
borderRadius: avatarSize / 2,
|
|
31638
|
-
}, accessibilityLabel: accessibilityLabel })) : (jsxRuntime.jsx(Text, { size: textSize, color: textColor, weight: "semibold", style: { textAlign: 'center' }, children: fallback || '?' })) }), online && (jsxRuntime.jsx(Indicator, { size:
|
|
31707
|
+
}, accessibilityLabel: accessibilityLabel })) : (jsxRuntime.jsx(Text, { size: textSize, color: textColor, weight: "semibold", style: { textAlign: 'center' }, children: fallback || '?' })) }), online && (jsxRuntime.jsx(Indicator, { size: indicatorSize, color: indicatorColor || theme.colors.success[5], borderColor: theme.colors.gray[0], placement: "bottom-right" }))] }));
|
|
31639
31708
|
if (label || description) {
|
|
31640
31709
|
return (jsxRuntime.jsxs(reactNative.View, { style: { flexDirection: 'row', alignItems: 'center' }, children: [content, showText && (jsxRuntime.jsxs(reactNative.View, { style: { marginLeft: gap, justifyContent: 'center' }, children: [label && (typeof label === 'string' ? (jsxRuntime.jsx(Text, { size: textSize, weight: "semibold", children: label })) : label), description && (typeof description === 'string' ? (jsxRuntime.jsx(Text, { size: textSize, color: theme.colors.gray[6], children: description })) : description)] }))] }));
|
|
31641
31710
|
}
|
|
@@ -33468,7 +33537,7 @@ const filterData = (data, filters, columns, searchValue, rowFeatureToggle) => {
|
|
|
33468
33537
|
return filteredData;
|
|
33469
33538
|
};
|
|
33470
33539
|
// DataTable component
|
|
33471
|
-
const DataTable = ({ id, data, columns, loading = false, error = null, emptyMessage = 'No data available', searchable = true, searchPlaceholder = 'Search...', searchValue: controlledSearchValue, onSearchChange, sortBy = [], onSortChange, filters = [], onFilterChange, pagination, onPaginationChange, selectable = false, selectedRows = [], onSelectionChange, getRowId = (_, index) => index, onRowClick, editMode = false, onEditModeChange, onCellEdit, bulkActions = [], variant = 'default', density = 'normal', height, virtual = false, style, hoverHighlight = true, enableColumnResizing = false, rowFeatureToggle, initialHiddenColumns = [], onColumnVisibilityChange, onColumnSettings, showColumnVisibilityManager = true, rowsPerPageOptions = [10, 25, 50, 100], showRowsPerPageControl = true, rowActions, actionsColumnWidth = 100, fullWidth = true,
|
|
33540
|
+
const DataTable = ({ id, data, columns, loading = false, error = null, emptyMessage = 'No data available', searchable = true, searchPlaceholder = 'Search...', searchValue: controlledSearchValue, onSearchChange, sortBy = [], onSortChange, filters = [], onFilterChange, pagination, onPaginationChange, selectable = false, selectedRows = [], onSelectionChange, getRowId = (_, index) => index, onRowClick, editMode = false, onEditModeChange, onCellEdit, bulkActions = [], variant = 'default', striped: stripedProp, density = 'normal', height, virtual = false, style, hoverHighlight = true, enableColumnResizing = false, rowFeatureToggle, initialHiddenColumns = [], onColumnVisibilityChange, onColumnSettings, showColumnVisibilityManager = true, rowsPerPageOptions = [10, 25, 50, 100], showRowsPerPageControl = true, rowActions, actionsColumnWidth = 100, fullWidth = true,
|
|
33472
33541
|
// Border styling props
|
|
33473
33542
|
rowBorderWidth, rowBorderColor, rowBorderStyle = 'solid', columnBorderWidth, columnBorderColor, columnBorderStyle = 'solid', showOuterBorder = false, outerBorderWidth = 1, outerBorderColor,
|
|
33474
33543
|
// Expandable rows props
|
|
@@ -33476,6 +33545,7 @@ expandableRowRender, initialExpandedRows = [], expandedRows: controlledExpandedR
|
|
|
33476
33545
|
const { spacingProps, otherProps } = extractSpacingProps(props);
|
|
33477
33546
|
const theme = useTheme();
|
|
33478
33547
|
const { isRTL } = useDirection();
|
|
33548
|
+
const isStriped = stripedProp !== null && stripedProp !== void 0 ? stripedProp : variant === 'striped';
|
|
33479
33549
|
// Local state
|
|
33480
33550
|
const [internalSearchValue, setInternalSearchValue] = React.useState('');
|
|
33481
33551
|
const [editingCell, setEditingCell] = React.useState(null);
|
|
@@ -33912,7 +33982,7 @@ expandableRowRender, initialExpandedRows = [], expandedRows: controlledExpandedR
|
|
|
33912
33982
|
const rowElement = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(TableTr, { selected: isSelected, onPress: () => onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row, rowIndex), style: {
|
|
33913
33983
|
backgroundColor: isSelected
|
|
33914
33984
|
? theme.colors.primary[1]
|
|
33915
|
-
:
|
|
33985
|
+
: isStriped && rowIndex % 2 === 1
|
|
33916
33986
|
? theme.colors.gray[0]
|
|
33917
33987
|
: 'transparent',
|
|
33918
33988
|
borderBottomWidth: rowBorderWidth || (variant === 'bordered' ? 1 : 0),
|
|
@@ -33992,7 +34062,7 @@ expandableRowRender, initialExpandedRows = [], expandedRows: controlledExpandedR
|
|
|
33992
34062
|
borderRadius: showOuterBorder ? 8 : 0
|
|
33993
34063
|
};
|
|
33994
34064
|
if (loading) {
|
|
33995
|
-
return (jsxRuntime.jsxs(reactNative.View, { style: [getSpacingStyles(spacingProps), style], ...otherProps, children: [renderHeader(), jsxRuntime.jsxs(Table, { striped:
|
|
34065
|
+
return (jsxRuntime.jsxs(reactNative.View, { style: [getSpacingStyles(spacingProps), style], ...otherProps, children: [renderHeader(), jsxRuntime.jsxs(Table, { striped: isStriped, withTableBorder: variant === 'bordered', withRowBorders: variant !== 'default', verticalSpacing: density === 'compact' ? 'xs' : density === 'comfortable' ? 'lg' : 'sm', fullWidth: fullWidth, children: [jsxRuntime.jsxs(TableTr, { style: { backgroundColor: theme.colors.gray[0] }, children: [selectable && (jsxRuntime.jsx(TableTh, { w: 50, children: jsxRuntime.jsx(reactNative.View, { style: { width: 20, height: 20, backgroundColor: theme.colors.gray[2], borderRadius: 4 } }) })), expandableRowRender && (jsxRuntime.jsx(TableTh, { w: 50, children: jsxRuntime.jsx(reactNative.View, { style: { width: 20, height: 20, backgroundColor: theme.colors.gray[2], borderRadius: 4 } }) })), visibleColumns.map(column => (jsxRuntime.jsx(TableTh, { w: column.width || columnWidths[column.key], minWidth: column.minWidth, children: jsxRuntime.jsx(reactNative.View, { style: {
|
|
33996
34066
|
height: 20,
|
|
33997
34067
|
backgroundColor: theme.colors.gray[2],
|
|
33998
34068
|
borderRadius: 4,
|
|
@@ -34014,9 +34084,9 @@ expandableRowRender, initialExpandedRows = [], expandedRows: controlledExpandedR
|
|
|
34014
34084
|
borderColor: theme.colors.error[2]
|
|
34015
34085
|
}, children: [jsxRuntime.jsx(Icon, { name: "error", size: 32, color: theme.colors.error[5], style: { marginBottom: 12 } }), jsxRuntime.jsx(Text, { variant: "h6", color: theme.colors.error[7], style: { marginBottom: 8 }, children: "Error Loading Data" }), jsxRuntime.jsx(Text, { variant: "p", colorVariant: "muted", style: { textAlign: 'center' }, children: error })] })] }));
|
|
34016
34086
|
}
|
|
34017
|
-
return (jsxRuntime.jsxs(reactNative.View, { style: [getSpacingStyles(spacingProps), style], ...otherProps, children: [renderHeader(), virtual ? (jsxRuntime.jsx(reactNative.View, { style: [{ width: '100%', overflow: 'hidden' }, tableBorderStyle], children: jsxRuntime.jsx(reactNative.ScrollView, { horizontal: true, showsHorizontalScrollIndicator: reactNative.Platform.OS === 'web', contentContainerStyle: minWidthValue ? { minWidth: minWidthValue } : undefined, children: jsxRuntime.jsxs(reactNative.View, { style: { flex: 1 }, children: [jsxRuntime.jsx(Table, { striped:
|
|
34087
|
+
return (jsxRuntime.jsxs(reactNative.View, { style: [getSpacingStyles(spacingProps), style], ...otherProps, children: [renderHeader(), virtual ? (jsxRuntime.jsx(reactNative.View, { style: [{ width: '100%', overflow: 'hidden' }, tableBorderStyle], children: jsxRuntime.jsx(reactNative.ScrollView, { horizontal: true, showsHorizontalScrollIndicator: reactNative.Platform.OS === 'web', contentContainerStyle: minWidthValue ? { minWidth: minWidthValue } : undefined, children: jsxRuntime.jsxs(reactNative.View, { style: { flex: 1 }, children: [jsxRuntime.jsx(Table, { striped: isStriped, withTableBorder: variant === 'bordered', withRowBorders: variant !== 'default', verticalSpacing: density === 'compact' ? 'xs' : density === 'comfortable' ? 'lg' : 'sm', fullWidth: fullWidth, children: headerRow }), processedData.length === 0 ? (jsxRuntime.jsx(Table, { striped: isStriped, withTableBorder: variant === 'bordered', withRowBorders: variant !== 'default', verticalSpacing: density === 'compact' ? 'xs' : density === 'comfortable' ? 'lg' : 'sm', fullWidth: fullWidth, children: emptyStateRow })) : (jsxRuntime.jsx(flashList.FlashList, { data: processedData, keyExtractor: (item, index) => String(getRowId(item, index)), renderItem: renderVirtualRow, ...flashListSizingProps, extraData: flashListExtraData, contentContainerStyle: { flexGrow: 1 }, showsVerticalScrollIndicator: reactNative.Platform.OS === 'web' }))] }) }) })) : (
|
|
34018
34088
|
// <TableScrollContainer style={tableBorderStyle} minWidth={minWidthValue}>
|
|
34019
|
-
jsxRuntime.jsxs(Table, { striped:
|
|
34089
|
+
jsxRuntime.jsxs(Table, { striped: isStriped, withTableBorder: variant === 'bordered', withRowBorders: variant !== 'default', verticalSpacing: density === 'compact' ? 'xs' : density === 'comfortable' ? 'lg' : 'sm', fullWidth //</TableScrollContainer>={fullWidth}
|
|
34020
34090
|
: true, children: [headerRow, processedData.length === 0 ? emptyStateRow : nonVirtualRows] })
|
|
34021
34091
|
// </TableScrollContainer>
|
|
34022
34092
|
), pagination && onPaginationChange && (jsxRuntime.jsx(reactNative.View, { style: {
|
|
@@ -37454,49 +37524,101 @@ const CarouselDot = React.memo(({ index, pageProgress, metrics, totalPages, loop
|
|
|
37454
37524
|
: { marginHorizontal: metrics.margin, height: baseDotSize, justifyContent: 'center' };
|
|
37455
37525
|
return (jsxRuntime.jsx(reactNative.Pressable, { onPress: handlePress, accessibilityRole: "button", accessibilityLabel: `Go to slide ${index + 1}`, style: containerStyle, children: jsxRuntime.jsx(Animated.View, { style: [{ borderRadius: baseDotSize / 2 }, animatedStyle] }) }));
|
|
37456
37526
|
});
|
|
37527
|
+
const getBreakpointName = (width) => {
|
|
37528
|
+
if (width >= 1200)
|
|
37529
|
+
return 'xl';
|
|
37530
|
+
if (width >= 992)
|
|
37531
|
+
return 'lg';
|
|
37532
|
+
if (width >= 768)
|
|
37533
|
+
return 'md';
|
|
37534
|
+
if (width >= 576)
|
|
37535
|
+
return 'sm';
|
|
37536
|
+
return 'xs';
|
|
37537
|
+
};
|
|
37538
|
+
const getViewportWidth = () => {
|
|
37539
|
+
if (reactNative.Platform.OS === 'web' && typeof window !== 'undefined' && typeof window.innerWidth === 'number') {
|
|
37540
|
+
return window.innerWidth;
|
|
37541
|
+
}
|
|
37542
|
+
const dimensions = reactNative.Dimensions.get('window');
|
|
37543
|
+
return typeof (dimensions === null || dimensions === void 0 ? void 0 : dimensions.width) === 'number' ? dimensions.width : 0;
|
|
37544
|
+
};
|
|
37457
37545
|
// Optimized breakpoint hook with debouncing
|
|
37458
37546
|
const useOptimizedBreakpoint = () => {
|
|
37459
|
-
const
|
|
37547
|
+
const computeState = () => {
|
|
37548
|
+
const width = getViewportWidth();
|
|
37549
|
+
return {
|
|
37550
|
+
width,
|
|
37551
|
+
breakpoint: getBreakpointName(width),
|
|
37552
|
+
};
|
|
37553
|
+
};
|
|
37554
|
+
const [state, setState] = React.useState(computeState);
|
|
37460
37555
|
React.useEffect(() => {
|
|
37461
37556
|
let timeoutId;
|
|
37462
|
-
const
|
|
37463
|
-
const
|
|
37464
|
-
|
|
37465
|
-
: reactNative.Dimensions.get('window').width;
|
|
37466
|
-
let newBreakpoint = 'sm';
|
|
37467
|
-
if (w >= 1200)
|
|
37468
|
-
newBreakpoint = 'xl';
|
|
37469
|
-
else if (w >= 992)
|
|
37470
|
-
newBreakpoint = 'lg';
|
|
37471
|
-
else if (w >= 768)
|
|
37472
|
-
newBreakpoint = 'md';
|
|
37473
|
-
else if (w >= 576)
|
|
37474
|
-
newBreakpoint = 'sm';
|
|
37475
|
-
else
|
|
37476
|
-
newBreakpoint = 'xs';
|
|
37477
|
-
setBreakpoint(prev => prev !== newBreakpoint ? newBreakpoint : prev);
|
|
37557
|
+
const update = () => {
|
|
37558
|
+
const next = computeState();
|
|
37559
|
+
setState(prev => (prev.breakpoint === next.breakpoint && prev.width === next.width) ? prev : next);
|
|
37478
37560
|
};
|
|
37479
|
-
const
|
|
37561
|
+
const debouncedUpdate = () => {
|
|
37480
37562
|
clearTimeout(timeoutId);
|
|
37481
|
-
timeoutId = setTimeout(
|
|
37563
|
+
timeoutId = setTimeout(update, 100); // Debounce resize events
|
|
37482
37564
|
};
|
|
37483
|
-
|
|
37484
|
-
if (reactNative.Platform.OS === 'web') {
|
|
37485
|
-
window.addEventListener('resize',
|
|
37565
|
+
update();
|
|
37566
|
+
if (reactNative.Platform.OS === 'web' && typeof window !== 'undefined') {
|
|
37567
|
+
window.addEventListener('resize', debouncedUpdate, { passive: true });
|
|
37486
37568
|
return () => {
|
|
37487
|
-
window.removeEventListener('resize',
|
|
37569
|
+
window.removeEventListener('resize', debouncedUpdate);
|
|
37488
37570
|
clearTimeout(timeoutId);
|
|
37489
37571
|
};
|
|
37490
37572
|
}
|
|
37491
|
-
|
|
37573
|
+
const subscription = reactNative.Dimensions.addEventListener('change', debouncedUpdate);
|
|
37574
|
+
return () => {
|
|
37575
|
+
subscription === null || subscription === void 0 ? void 0 : subscription.remove();
|
|
37576
|
+
clearTimeout(timeoutId);
|
|
37577
|
+
};
|
|
37492
37578
|
}, []);
|
|
37493
|
-
return
|
|
37579
|
+
return state;
|
|
37580
|
+
};
|
|
37581
|
+
const parseMediaQuery = (query) => {
|
|
37582
|
+
const minMatch = query.match(/min-width:\s*(\d+)px/);
|
|
37583
|
+
const maxMatch = query.match(/max-width:\s*(\d+)px/);
|
|
37584
|
+
return {
|
|
37585
|
+
min: minMatch ? parseInt(minMatch[1], 10) : undefined,
|
|
37586
|
+
max: maxMatch ? parseInt(maxMatch[1], 10) : undefined,
|
|
37587
|
+
};
|
|
37588
|
+
};
|
|
37589
|
+
const matchQuery = (query, width) => {
|
|
37590
|
+
const { min, max } = parseMediaQuery(query);
|
|
37591
|
+
if (min != null && width < min)
|
|
37592
|
+
return false;
|
|
37593
|
+
if (max != null && width > max)
|
|
37594
|
+
return false;
|
|
37595
|
+
return true;
|
|
37596
|
+
};
|
|
37597
|
+
const mergeBreakpointProps = (baseProps, breakpointProps, width) => {
|
|
37598
|
+
if (!breakpointProps)
|
|
37599
|
+
return baseProps;
|
|
37600
|
+
const sortedEntries = Object.entries(breakpointProps).sort((a, b) => {
|
|
37601
|
+
var _a, _b;
|
|
37602
|
+
const aMin = (_a = parseMediaQuery(a[0]).min) !== null && _a !== void 0 ? _a : 0;
|
|
37603
|
+
const bMin = (_b = parseMediaQuery(b[0]).min) !== null && _b !== void 0 ? _b : 0;
|
|
37604
|
+
return aMin - bMin;
|
|
37605
|
+
});
|
|
37606
|
+
let resolvedProps = { ...baseProps };
|
|
37607
|
+
sortedEntries.forEach(([query, value]) => {
|
|
37608
|
+
const shouldApply = width != null ? matchQuery(query, width) : (reactNative.Platform.OS === 'web' && typeof window !== 'undefined' ? window.matchMedia(query).matches : false);
|
|
37609
|
+
if (shouldApply) {
|
|
37610
|
+
resolvedProps = { ...resolvedProps, ...value };
|
|
37611
|
+
}
|
|
37612
|
+
});
|
|
37613
|
+
return resolvedProps;
|
|
37494
37614
|
};
|
|
37495
|
-
const Carousel = (
|
|
37496
|
-
const {
|
|
37615
|
+
const Carousel = (incomingProps) => {
|
|
37616
|
+
const { breakpoint, width: viewportWidth } = useOptimizedBreakpoint();
|
|
37617
|
+
const mergedProps = React.useMemo(() => mergeBreakpointProps(incomingProps, incomingProps.breakpoints, viewportWidth), [incomingProps, viewportWidth]);
|
|
37618
|
+
const { children, orientation = 'horizontal', height = 200, showDots = true, showArrows = true, loop = true, autoPlay = false, autoPlayInterval = 3000, itemsPerPage = 1, slidesToScroll, slideSize, slideGap, itemGap = 16, containScroll = 'trimSnaps', startIndex, align = 'start', dragFree = false, skipSnaps = true, dragThreshold, duration, breakpoints: _breakpoints, onSlideChange, style, itemStyle, arrowSize = 'md', dotSize = 'md', // currently uniform size; active expands
|
|
37497
37619
|
snapToItem = true, // kept for API parity (engine handles snapping)
|
|
37498
37620
|
windowSize = 0, // 0 means no virtualization
|
|
37499
|
-
reducedMotion = false, ...rest } =
|
|
37621
|
+
reducedMotion = false, ...rest } = mergedProps;
|
|
37500
37622
|
const { spacingProps, otherProps } = extractSpacingProps(rest);
|
|
37501
37623
|
const spacingStyles = getSpacingStyles(spacingProps);
|
|
37502
37624
|
const theme = useTheme();
|
|
@@ -37508,10 +37630,9 @@ const Carousel = (props) => {
|
|
|
37508
37630
|
// progress holds absolute item progress (fractional, not modulo) supplied by engine
|
|
37509
37631
|
const progress = Animated.useSharedValue(0);
|
|
37510
37632
|
const [currentIndex, setCurrentIndex] = React.useState(0);
|
|
37633
|
+
const hasInitializedRef = React.useRef(false);
|
|
37511
37634
|
const itemsArray = React.useMemo(() => React.Children.toArray(children), [children]);
|
|
37512
37635
|
const totalItems = itemsArray.length;
|
|
37513
|
-
// Use optimized breakpoint detection with debouncing
|
|
37514
|
-
const breakpoint = useOptimizedBreakpoint();
|
|
37515
37636
|
const resolvedGap = React.useMemo(() => {
|
|
37516
37637
|
const raw = resolveResponsive(slideGap, breakpoint);
|
|
37517
37638
|
if (raw == null)
|
|
@@ -37526,7 +37647,7 @@ const Carousel = (props) => {
|
|
|
37526
37647
|
}, [slideGap, breakpoint, itemGap]);
|
|
37527
37648
|
const isVertical = orientation === 'vertical';
|
|
37528
37649
|
const containerSize = isVertical ? containerHeight : containerWidth;
|
|
37529
|
-
const
|
|
37650
|
+
const desiredItemSize = React.useMemo(() => {
|
|
37530
37651
|
if (containerSize <= 0)
|
|
37531
37652
|
return 0;
|
|
37532
37653
|
const rawSize = resolveResponsive(slideSize, breakpoint);
|
|
@@ -37552,28 +37673,166 @@ const Carousel = (props) => {
|
|
|
37552
37673
|
}
|
|
37553
37674
|
return (containerSize - resolvedGap * (itemsPerPage - 1)) / itemsPerPage;
|
|
37554
37675
|
}, [slideSize, breakpoint, containerSize, itemsPerPage, resolvedGap]);
|
|
37676
|
+
const hasLayout = isVertical ? containerHeight > 0 : containerWidth > 0;
|
|
37677
|
+
const baseItemsPerPage = Math.max(1, itemsPerPage);
|
|
37678
|
+
const slidesToScrollValue = Math.max(1, slidesToScroll !== null && slidesToScroll !== void 0 ? slidesToScroll : baseItemsPerPage);
|
|
37679
|
+
const containMode = containScroll === false
|
|
37680
|
+
? 'none'
|
|
37681
|
+
: containScroll === 'keepSnaps'
|
|
37682
|
+
? 'keepSnaps'
|
|
37683
|
+
: 'trimSnaps';
|
|
37684
|
+
const isDragFree = !!dragFree;
|
|
37685
|
+
const allowSkipSnaps = skipSnaps !== null && skipSnaps !== void 0 ? skipSnaps : true;
|
|
37686
|
+
const dragThresholdValue = typeof dragThreshold === 'number'
|
|
37687
|
+
? Math.max(dragThreshold, 0)
|
|
37688
|
+
: undefined;
|
|
37689
|
+
const visibleSlides = React.useMemo(() => {
|
|
37690
|
+
if (!hasLayout || containerSize <= 0)
|
|
37691
|
+
return baseItemsPerPage;
|
|
37692
|
+
if (desiredItemSize <= 0)
|
|
37693
|
+
return baseItemsPerPage;
|
|
37694
|
+
const maxFit = Math.max(1, Math.floor((containerSize + resolvedGap) / (desiredItemSize + resolvedGap)));
|
|
37695
|
+
if (slideSize == null) {
|
|
37696
|
+
return Math.min(baseItemsPerPage, maxFit);
|
|
37697
|
+
}
|
|
37698
|
+
return maxFit;
|
|
37699
|
+
}, [hasLayout, containerSize, desiredItemSize, resolvedGap, baseItemsPerPage, slideSize]);
|
|
37700
|
+
const cardSize = React.useMemo(() => {
|
|
37701
|
+
if (!hasLayout)
|
|
37702
|
+
return desiredItemSize;
|
|
37703
|
+
if (visibleSlides <= 1) {
|
|
37704
|
+
if (desiredItemSize > 0)
|
|
37705
|
+
return desiredItemSize;
|
|
37706
|
+
return containerSize > 0 ? containerSize : desiredItemSize;
|
|
37707
|
+
}
|
|
37708
|
+
const totalGap = resolvedGap * (visibleSlides - 1);
|
|
37709
|
+
const available = Math.max(containerSize - totalGap, 0);
|
|
37710
|
+
return available / visibleSlides;
|
|
37711
|
+
}, [hasLayout, desiredItemSize, visibleSlides, resolvedGap, containerSize]);
|
|
37712
|
+
const slideExtent = React.useMemo(() => {
|
|
37713
|
+
if (!hasLayout || cardSize <= 0)
|
|
37714
|
+
return undefined;
|
|
37715
|
+
return cardSize + resolvedGap;
|
|
37716
|
+
}, [hasLayout, cardSize, resolvedGap]);
|
|
37717
|
+
const scrollStep = React.useMemo(() => {
|
|
37718
|
+
if (totalItems === 0)
|
|
37719
|
+
return slidesToScrollValue;
|
|
37720
|
+
return Math.min(slidesToScrollValue, Math.max(1, totalItems));
|
|
37721
|
+
}, [slidesToScrollValue, totalItems]);
|
|
37722
|
+
const maxScrollDistancePerSwipe = React.useMemo(() => {
|
|
37723
|
+
if (allowSkipSnaps || slideExtent == null)
|
|
37724
|
+
return undefined;
|
|
37725
|
+
return slideExtent * scrollStep;
|
|
37726
|
+
}, [allowSkipSnaps, slideExtent, scrollStep]);
|
|
37727
|
+
const lastStart = React.useMemo(() => Math.max(totalItems - visibleSlides, 0), [totalItems, visibleSlides]);
|
|
37728
|
+
const pageStartIndices = React.useMemo(() => {
|
|
37729
|
+
if (totalItems === 0)
|
|
37730
|
+
return [];
|
|
37731
|
+
if (loop) {
|
|
37732
|
+
const count = Math.max(1, Math.ceil(totalItems / scrollStep));
|
|
37733
|
+
return Array.from({ length: count }, (_, idx) => (idx * scrollStep) % totalItems);
|
|
37734
|
+
}
|
|
37735
|
+
const starts = [];
|
|
37736
|
+
const seen = new Set();
|
|
37737
|
+
const limit = containMode === 'none' ? Math.max(totalItems - 1, 0) : lastStart;
|
|
37738
|
+
const addStart = (value) => {
|
|
37739
|
+
if (!seen.has(value)) {
|
|
37740
|
+
seen.add(value);
|
|
37741
|
+
starts.push(Math.max(0, value));
|
|
37742
|
+
}
|
|
37743
|
+
};
|
|
37744
|
+
for (let start = 0; start <= limit; start += scrollStep) {
|
|
37745
|
+
const value = containMode === 'trimSnaps'
|
|
37746
|
+
? Math.min(start, lastStart)
|
|
37747
|
+
: start;
|
|
37748
|
+
addStart(value);
|
|
37749
|
+
}
|
|
37750
|
+
if (containMode !== 'trimSnaps') {
|
|
37751
|
+
addStart(lastStart);
|
|
37752
|
+
}
|
|
37753
|
+
starts.sort((a, b) => a - b);
|
|
37754
|
+
return starts;
|
|
37755
|
+
}, [totalItems, loop, scrollStep, containMode, lastStart]);
|
|
37756
|
+
const pagedItems = React.useMemo(() => {
|
|
37757
|
+
if (!totalItems)
|
|
37758
|
+
return [];
|
|
37759
|
+
return pageStartIndices.map(start => {
|
|
37760
|
+
const group = [];
|
|
37761
|
+
for (let offset = 0; offset < visibleSlides; offset++) {
|
|
37762
|
+
const targetIndex = start + offset;
|
|
37763
|
+
if (loop) {
|
|
37764
|
+
const normalized = ((targetIndex % totalItems) + totalItems) % totalItems;
|
|
37765
|
+
group.push(itemsArray[normalized]);
|
|
37766
|
+
}
|
|
37767
|
+
else if (targetIndex < totalItems) {
|
|
37768
|
+
group.push(itemsArray[targetIndex]);
|
|
37769
|
+
}
|
|
37770
|
+
}
|
|
37771
|
+
return group;
|
|
37772
|
+
});
|
|
37773
|
+
}, [pageStartIndices, visibleSlides, loop, totalItems, itemsArray]);
|
|
37774
|
+
const totalPages = pagedItems.length;
|
|
37775
|
+
const normalizedStartIndex = React.useMemo(() => {
|
|
37776
|
+
if (!totalItems)
|
|
37777
|
+
return 0;
|
|
37778
|
+
const rawIndex = startIndex !== null && startIndex !== void 0 ? startIndex : 0;
|
|
37779
|
+
if (loop) {
|
|
37780
|
+
return ((rawIndex % totalItems) + totalItems) % totalItems;
|
|
37781
|
+
}
|
|
37782
|
+
return Math.max(0, Math.min(rawIndex, Math.max(totalItems - 1, 0)));
|
|
37783
|
+
}, [startIndex, totalItems, loop]);
|
|
37784
|
+
const initialPageStart = React.useMemo(() => {
|
|
37785
|
+
if (!totalItems)
|
|
37786
|
+
return 0;
|
|
37787
|
+
const base = Math.floor(normalizedStartIndex / scrollStep) * scrollStep;
|
|
37788
|
+
if (loop) {
|
|
37789
|
+
return totalItems ? base % totalItems : 0;
|
|
37790
|
+
}
|
|
37791
|
+
if (containMode === 'none') {
|
|
37792
|
+
return Math.min(base, Math.max(totalItems - 1, 0));
|
|
37793
|
+
}
|
|
37794
|
+
if (containMode === 'keepSnaps') {
|
|
37795
|
+
return Math.min(base, Math.max(totalItems - 1, 0));
|
|
37796
|
+
}
|
|
37797
|
+
return Math.min(base, lastStart);
|
|
37798
|
+
}, [normalizedStartIndex, scrollStep, loop, totalItems, containMode, lastStart]);
|
|
37799
|
+
const initialPageIndex = React.useMemo(() => {
|
|
37800
|
+
if (!pageStartIndices.length)
|
|
37801
|
+
return 0;
|
|
37802
|
+
const idx = pageStartIndices.indexOf(initialPageStart);
|
|
37803
|
+
return idx >= 0 ? idx : 0;
|
|
37804
|
+
}, [pageStartIndices, initialPageStart]);
|
|
37555
37805
|
const handleLayout = React.useCallback((e) => {
|
|
37556
37806
|
setContainerWidth(e.nativeEvent.layout.width);
|
|
37557
37807
|
setContainerHeight(e.nativeEvent.layout.height);
|
|
37558
37808
|
}, []);
|
|
37559
|
-
const
|
|
37560
|
-
if (!carouselRef.current)
|
|
37809
|
+
const scrollToPage = React.useCallback((index, animated = true) => {
|
|
37810
|
+
if (!carouselRef.current || totalPages === 0)
|
|
37561
37811
|
return;
|
|
37562
|
-
|
|
37563
|
-
return;
|
|
37564
|
-
const clamped = ((index % totalItems) + totalItems) % totalItems;
|
|
37812
|
+
const clamped = ((index % totalPages) + totalPages) % totalPages;
|
|
37565
37813
|
const delta = clamped - currentIndex;
|
|
37566
|
-
if (delta === 0)
|
|
37814
|
+
if (delta === 0) {
|
|
37815
|
+
if (!animated) {
|
|
37816
|
+
progress.value = clamped;
|
|
37817
|
+
setCurrentIndex(clamped);
|
|
37818
|
+
}
|
|
37567
37819
|
return;
|
|
37568
|
-
|
|
37820
|
+
}
|
|
37569
37821
|
let count = delta;
|
|
37570
37822
|
if (loop) {
|
|
37571
|
-
const alt = delta > 0 ? delta -
|
|
37823
|
+
const alt = delta > 0 ? delta - totalPages : delta + totalPages;
|
|
37572
37824
|
if (Math.abs(alt) < Math.abs(count))
|
|
37573
37825
|
count = alt;
|
|
37574
37826
|
}
|
|
37575
|
-
carouselRef.current.scrollTo({ count, animated
|
|
37576
|
-
|
|
37827
|
+
carouselRef.current.scrollTo({ count, animated });
|
|
37828
|
+
if (!animated) {
|
|
37829
|
+
progress.value = clamped;
|
|
37830
|
+
setCurrentIndex(clamped);
|
|
37831
|
+
}
|
|
37832
|
+
}, [carouselRef, totalPages, currentIndex, loop, progress]);
|
|
37833
|
+
const goTo = React.useCallback((index) => {
|
|
37834
|
+
scrollToPage(index, true);
|
|
37835
|
+
}, [scrollToPage]);
|
|
37577
37836
|
const goPrev = React.useCallback(() => {
|
|
37578
37837
|
if (!carouselRef.current)
|
|
37579
37838
|
return;
|
|
@@ -37584,13 +37843,22 @@ const Carousel = (props) => {
|
|
|
37584
37843
|
return;
|
|
37585
37844
|
carouselRef.current.next();
|
|
37586
37845
|
}, []);
|
|
37587
|
-
const totalPages = React.useMemo(() => totalItems, [totalItems]);
|
|
37588
37846
|
// Page progress derived directly from absolute item progress
|
|
37589
37847
|
const pageProgress = Animated.useDerivedValue(() => {
|
|
37590
37848
|
return progress.value;
|
|
37591
37849
|
}, []);
|
|
37592
37850
|
const arrowMetrics = React.useMemo(() => resolveCarouselArrowMetrics(arrowSize), [arrowSize]);
|
|
37593
37851
|
const dotMetrics = React.useMemo(() => resolveCarouselDotMetrics(dotSize), [dotSize]);
|
|
37852
|
+
const alignJustify = React.useMemo(() => {
|
|
37853
|
+
switch (align) {
|
|
37854
|
+
case 'center':
|
|
37855
|
+
return 'center';
|
|
37856
|
+
case 'end':
|
|
37857
|
+
return 'flex-end';
|
|
37858
|
+
default:
|
|
37859
|
+
return 'flex-start';
|
|
37860
|
+
}
|
|
37861
|
+
}, [align]);
|
|
37594
37862
|
// Memoized render functions to prevent unnecessary re-renders
|
|
37595
37863
|
const renderDots = React.useMemo(() => {
|
|
37596
37864
|
if (!showDots || totalPages <= 1)
|
|
@@ -37606,7 +37874,7 @@ const Carousel = (props) => {
|
|
|
37606
37874
|
}, [showDots, totalPages, pageProgress, dotMetrics, loop, theme, goTo, isVertical, isRTL]);
|
|
37607
37875
|
// Arrows
|
|
37608
37876
|
const renderArrows = () => {
|
|
37609
|
-
if (!showArrows ||
|
|
37877
|
+
if (!showArrows || totalPages <= 1)
|
|
37610
37878
|
return null;
|
|
37611
37879
|
const buttonSize = arrowMetrics.buttonSizeToken;
|
|
37612
37880
|
const iconSize = arrowMetrics.iconSize;
|
|
@@ -37643,37 +37911,69 @@ const Carousel = (props) => {
|
|
|
37643
37911
|
}, children: jsxRuntime.jsx(Button, { size: buttonSize, variant: "secondary", icon: jsxRuntime.jsx(Icon, { name: isRTL ? 'chevron-left' : 'chevron-right', size: iconSize }), onPress: goNext, radius: "full" }) })] }));
|
|
37644
37912
|
};
|
|
37645
37913
|
// Autoplay: if library autoPlay not sufficient for pause logic, we can just pass through for now.
|
|
37646
|
-
const enableAutoPlay = autoPlay &&
|
|
37914
|
+
const enableAutoPlay = autoPlay && totalPages > 1;
|
|
37915
|
+
React.useEffect(() => {
|
|
37916
|
+
if (!carouselRef.current || totalPages === 0 || !hasLayout)
|
|
37917
|
+
return;
|
|
37918
|
+
const controlledStart = startIndex != null;
|
|
37919
|
+
if (controlledStart) {
|
|
37920
|
+
scrollToPage(initialPageIndex, false);
|
|
37921
|
+
return;
|
|
37922
|
+
}
|
|
37923
|
+
if (!hasInitializedRef.current) {
|
|
37924
|
+
scrollToPage(initialPageIndex, false);
|
|
37925
|
+
hasInitializedRef.current = true;
|
|
37926
|
+
}
|
|
37927
|
+
}, [scrollToPage, initialPageIndex, startIndex, totalPages, hasLayout]);
|
|
37647
37928
|
return (jsxRuntime.jsxs(reactNative.View, { ref: containerRef, style: [
|
|
37648
37929
|
{
|
|
37930
|
+
width: '100%',
|
|
37649
37931
|
position: 'relative',
|
|
37650
37932
|
...(isVertical ? { flexDirection: 'row' } : {})
|
|
37651
37933
|
},
|
|
37652
37934
|
spacingStyles,
|
|
37653
37935
|
style
|
|
37654
|
-
], onLayout: handleLayout, ...otherProps, children: [jsxRuntime.jsx(reactNative.View, { style: { flex: 1 }, children:
|
|
37936
|
+
], onLayout: handleLayout, ...otherProps, children: [jsxRuntime.jsx(reactNative.View, { style: { flex: 1 }, children: hasLayout && pagedItems.length > 0 && cardSize > 0 && (jsxRuntime.jsx(ReanimatedCarousel, { ref: carouselRef, width: isVertical ? containerWidth : containerWidth, height: isVertical ? containerHeight : height, style: isVertical ? { height: containerHeight } : { width: containerWidth }, vertical: isVertical, loop: loop, autoPlay: enableAutoPlay, autoPlayInterval: autoPlayInterval, data: pagedItems, pagingEnabled: isDragFree ? false : snapToItem, snapEnabled: isDragFree ? false : undefined, windowSize: windowSize > 0 ? windowSize : undefined, scrollAnimationDuration: duration,
|
|
37655
37937
|
// Performance optimizations
|
|
37656
37938
|
overscrollEnabled: false, enabled: !reducedMotion, withAnimation: reducedMotion ?
|
|
37657
37939
|
{ type: 'timing', config: { duration: 100 } } :
|
|
37658
|
-
{ type: 'spring', config: { damping: 60, stiffness: 150 } }, onProgressChange: (offset, absolute) => {
|
|
37940
|
+
{ type: 'spring', config: { damping: 60, stiffness: 150 } }, maxScrollDistancePerSwipe: maxScrollDistancePerSwipe, minScrollDistancePerSwipe: dragThresholdValue, onProgressChange: (offset, absolute) => {
|
|
37659
37941
|
// absolute may be undefined in some versions; fallback to offset
|
|
37660
37942
|
const val = typeof absolute === 'number' ? absolute : offset;
|
|
37661
37943
|
progress.value = val;
|
|
37662
|
-
const ci =
|
|
37944
|
+
const ci = totalPages > 0
|
|
37945
|
+
? ((Math.round(val) % totalPages) + totalPages) % totalPages
|
|
37946
|
+
: 0;
|
|
37663
37947
|
if (ci !== currentIndex) {
|
|
37664
37948
|
setCurrentIndex(ci);
|
|
37665
37949
|
onSlideChange === null || onSlideChange === void 0 ? void 0 : onSlideChange(ci);
|
|
37666
37950
|
}
|
|
37667
|
-
}, renderItem: ({ item, index }) =>
|
|
37668
|
-
|
|
37669
|
-
|
|
37670
|
-
|
|
37671
|
-
|
|
37672
|
-
|
|
37673
|
-
|
|
37674
|
-
|
|
37675
|
-
|
|
37676
|
-
|
|
37951
|
+
}, renderItem: ({ item, index }) => {
|
|
37952
|
+
const pageItems = Array.isArray(item) ? item : [item];
|
|
37953
|
+
const pageWidth = isVertical ? containerWidth : containerWidth;
|
|
37954
|
+
const pageHeight = isVertical ? containerHeight : height;
|
|
37955
|
+
const justify = containMode === 'trimSnaps' ? 'flex-start' : alignJustify;
|
|
37956
|
+
return (jsxRuntime.jsx(reactNative.View, { style: [
|
|
37957
|
+
{
|
|
37958
|
+
width: pageWidth,
|
|
37959
|
+
height: pageHeight,
|
|
37960
|
+
justifyContent: 'center',
|
|
37961
|
+
},
|
|
37962
|
+
itemStyle,
|
|
37963
|
+
], accessibilityLabel: `Carousel item ${index + 1} of ${totalPages}`, children: jsxRuntime.jsx(reactNative.View, { style: {
|
|
37964
|
+
flexDirection: isVertical ? 'column' : 'row',
|
|
37965
|
+
alignItems: 'stretch',
|
|
37966
|
+
justifyContent: justify,
|
|
37967
|
+
flexWrap: 'nowrap',
|
|
37968
|
+
flex: 1,
|
|
37969
|
+
}, children: pageItems.map((child, childIndex) => (jsxRuntime.jsx(reactNative.View, { style: {
|
|
37970
|
+
width: isVertical ? '100%' : cardSize,
|
|
37971
|
+
height: isVertical ? cardSize : '100%',
|
|
37972
|
+
marginRight: !isVertical && childIndex < pageItems.length - 1 ? resolvedGap : 0,
|
|
37973
|
+
marginBottom: isVertical && childIndex < pageItems.length - 1 ? resolvedGap : 0,
|
|
37974
|
+
flexShrink: 0,
|
|
37975
|
+
}, children: child }, childIndex))) }) }));
|
|
37976
|
+
} })) }), renderArrows(), renderDots] }));
|
|
37677
37977
|
};
|
|
37678
37978
|
|
|
37679
37979
|
// Types extracted to types.ts
|