@idealyst/components 1.1.7 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/plugin/web.js +280 -532
- package/src/Accordion/Accordion.native.tsx +8 -6
- package/src/Accordion/Accordion.styles.old.tsx +298 -0
- package/src/Accordion/Accordion.styles.tsx +102 -236
- package/src/Accordion/Accordion.web.tsx +1 -3
- package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +94 -0
- package/src/ActivityIndicator/ActivityIndicator.styles.tsx +44 -74
- package/src/Alert/Alert.native.tsx +16 -6
- package/src/Alert/Alert.styles.old.tsx +209 -0
- package/src/Alert/Alert.styles.tsx +67 -149
- package/src/Alert/Alert.web.tsx +3 -4
- package/src/Avatar/Avatar.styles.old.tsx +99 -0
- package/src/Avatar/Avatar.styles.tsx +35 -80
- package/src/Badge/Badge.styles.old.tsx +157 -0
- package/src/Badge/Badge.styles.tsx +61 -121
- package/src/Badge/Badge.web.tsx +8 -15
- package/src/Breadcrumb/Breadcrumb.styles.old.tsx +231 -0
- package/src/Breadcrumb/Breadcrumb.styles.tsx +83 -200
- package/src/Breadcrumb/Breadcrumb.web.tsx +31 -30
- package/src/Button/Button.native.tsx +14 -21
- package/src/Button/Button.styles.tsx +103 -140
- package/src/Button/Button.web.tsx +9 -19
- package/src/Card/Card.native.tsx +7 -11
- package/src/Card/Card.styles.old.tsx +160 -0
- package/src/Card/Card.styles.tsx +105 -142
- package/src/Card/Card.web.tsx +5 -4
- package/src/Checkbox/Checkbox.native.tsx +9 -5
- package/src/Checkbox/Checkbox.styles.old.tsx +271 -0
- package/src/Checkbox/Checkbox.styles.tsx +104 -216
- package/src/Checkbox/Checkbox.web.tsx +7 -8
- package/src/Chip/Chip.styles.old.tsx +184 -0
- package/src/Chip/Chip.styles.tsx +34 -72
- package/src/Chip/Chip.web.tsx +3 -5
- package/src/Dialog/Dialog.native.tsx +7 -4
- package/src/Dialog/Dialog.styles.old.tsx +202 -0
- package/src/Dialog/Dialog.styles.tsx +69 -133
- package/src/Dialog/Dialog.web.tsx +3 -3
- package/src/Dialog/types.ts +1 -1
- package/src/Divider/Divider.styles.old.tsx +172 -0
- package/src/Divider/Divider.styles.tsx +62 -84
- package/src/Icon/Icon.native.tsx +8 -8
- package/src/Icon/Icon.styles.old.tsx +81 -0
- package/src/Icon/Icon.styles.tsx +52 -66
- package/src/Icon/Icon.web.tsx +62 -21
- package/src/Icon/IconRegistry.native.ts +41 -0
- package/src/Icon/IconRegistry.ts +107 -0
- package/src/Icon/IconSvg/IconSvg.web.tsx +28 -5
- package/src/Icon/icon-resolver.ts +12 -43
- package/src/Icon/index.native.ts +2 -1
- package/src/Icon/index.ts +1 -0
- package/src/Icon/index.web.ts +1 -0
- package/src/Image/Image.styles.old.tsx +69 -0
- package/src/Image/Image.styles.tsx +46 -60
- package/src/Input/Input.native.tsx +138 -53
- package/src/Input/Input.styles.old.tsx +289 -0
- package/src/Input/Input.styles.tsx +134 -232
- package/src/Input/Input.web.tsx +5 -8
- package/src/List/List.native.tsx +5 -2
- package/src/List/List.styles.old.tsx +242 -0
- package/src/List/List.styles.tsx +179 -215
- package/src/List/ListItem.native.tsx +16 -11
- package/src/List/ListItem.web.tsx +26 -16
- package/src/Menu/Menu.styles.old.tsx +197 -0
- package/src/Menu/Menu.styles.tsx +68 -150
- package/src/Menu/MenuItem.native.tsx +5 -3
- package/src/Menu/MenuItem.styles.old.tsx +114 -0
- package/src/Menu/MenuItem.styles.tsx +57 -89
- package/src/Menu/MenuItem.web.tsx +10 -7
- package/src/Popover/Popover.native.tsx +10 -4
- package/src/Popover/Popover.styles.old.tsx +135 -0
- package/src/Popover/Popover.styles.tsx +51 -112
- package/src/Pressable/Pressable.styles.old.tsx +27 -0
- package/src/Pressable/Pressable.styles.tsx +35 -27
- package/src/Progress/Progress.styles.old.tsx +200 -0
- package/src/Progress/Progress.styles.tsx +75 -164
- package/src/RadioButton/RadioButton.native.tsx +4 -3
- package/src/RadioButton/RadioButton.styles.old.tsx +175 -0
- package/src/RadioButton/RadioButton.styles.tsx +83 -154
- package/src/RadioButton/RadioButton.web.tsx +2 -2
- package/src/SVGImage/SVGImage.styles.old.tsx +86 -0
- package/src/SVGImage/SVGImage.styles.tsx +35 -78
- package/src/Screen/Screen.native.tsx +19 -26
- package/src/Screen/Screen.styles.old.tsx +87 -0
- package/src/Screen/Screen.styles.tsx +103 -68
- package/src/Screen/Screen.web.tsx +2 -2
- package/src/Select/Select.native.tsx +42 -33
- package/src/Select/Select.styles.old.tsx +353 -0
- package/src/Select/Select.styles.tsx +214 -300
- package/src/Select/Select.web.tsx +45 -33
- package/src/Skeleton/Skeleton.styles.old.tsx +67 -0
- package/src/Skeleton/Skeleton.styles.tsx +29 -53
- package/src/Slider/Slider.styles.old.tsx +259 -0
- package/src/Slider/Slider.styles.tsx +153 -234
- package/src/Slider/Slider.web.tsx +2 -4
- package/src/Switch/Switch.native.tsx +9 -7
- package/src/Switch/Switch.styles.old.tsx +203 -0
- package/src/Switch/Switch.styles.tsx +101 -174
- package/src/Switch/Switch.web.tsx +7 -8
- package/src/TabBar/TabBar.native.tsx +3 -2
- package/src/TabBar/TabBar.styles.old.tsx +343 -0
- package/src/TabBar/TabBar.styles.tsx +145 -279
- package/src/Table/Table.native.tsx +180 -68
- package/src/Table/Table.styles.old.tsx +311 -0
- package/src/Table/Table.styles.tsx +140 -281
- package/src/Table/Table.web.tsx +169 -70
- package/src/Text/Text.native.tsx +1 -3
- package/src/Text/Text.style.demo.tsx +16 -0
- package/src/Text/Text.styles.old.tsx +219 -0
- package/src/Text/Text.styles.tsx +94 -84
- package/src/Text/Text.web.tsx +3 -2
- package/src/Text/index.ts +1 -0
- package/src/TextArea/TextArea.native.tsx +21 -8
- package/src/TextArea/TextArea.styles.old.tsx +213 -0
- package/src/TextArea/TextArea.styles.tsx +87 -187
- package/src/TextArea/TextArea.web.tsx +17 -6
- package/src/Tooltip/Tooltip.styles.old.tsx +82 -0
- package/src/Tooltip/Tooltip.styles.tsx +32 -56
- package/src/Video/Video.styles.old.tsx +51 -0
- package/src/Video/Video.styles.tsx +32 -44
- package/src/View/View.native.tsx +41 -13
- package/src/View/View.styles.old.tsx +125 -0
- package/src/View/View.styles.tsx +76 -106
- package/src/View/View.web.tsx +5 -21
- package/src/View/types.ts +31 -3
- package/src/examples/ButtonExamples.tsx +20 -0
- package/src/examples/CardExamples.tsx +0 -6
- package/src/extensions/extendComponent.ts +61 -0
- package/src/index.ts +1 -1
|
@@ -2,7 +2,6 @@ import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
|
|
2
2
|
// @ts-ignore - web-specific import
|
|
3
3
|
import { getWebProps } from 'react-native-unistyles/web';
|
|
4
4
|
import { IconSvg } from '../Icon/IconSvg/IconSvg.web';
|
|
5
|
-
import { resolveIconPath } from '../Icon/icon-resolver';
|
|
6
5
|
import useMergeRefs from '../hooks/useMergeRefs';
|
|
7
6
|
import { PositionedPortal } from '../internal/PositionedPortal';
|
|
8
7
|
import { selectStyles } from './Select.styles';
|
|
@@ -175,14 +174,31 @@ const Select = forwardRef<HTMLDivElement, SelectProps>(({
|
|
|
175
174
|
setFocusedIndex(0);
|
|
176
175
|
};
|
|
177
176
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
// Get dynamic styles - call as functions for theme reactivity
|
|
178
|
+
const containerStyle = (selectStyles.container as any)({});
|
|
179
|
+
const labelStyle = (selectStyles.label as any)({});
|
|
180
|
+
const triggerStyle = (selectStyles.trigger as any)({ type, intent, disabled, error, focused: isOpen });
|
|
181
|
+
const triggerContentStyle = (selectStyles.triggerContent as any)({});
|
|
182
|
+
const triggerTextStyle = (selectStyles.triggerText as any)({});
|
|
183
|
+
const placeholderStyle = (selectStyles.placeholder as any)({});
|
|
184
|
+
const iconStyle = (selectStyles.icon as any)({});
|
|
185
|
+
const chevronStyle = (selectStyles.chevron as any)({});
|
|
186
|
+
const chevronOpenStyle = (selectStyles.chevronOpen as any)({});
|
|
187
|
+
const dropdownStyle = (selectStyles.dropdown as any)({});
|
|
188
|
+
const searchContainerStyle = (selectStyles.searchContainer as any)({});
|
|
189
|
+
const searchInputStyle = (selectStyles.searchInput as any)({});
|
|
190
|
+
const optionsListStyle = (selectStyles.optionsList as any)({});
|
|
191
|
+
const optionStyle = (selectStyles.option as any)({});
|
|
192
|
+
const optionFocusedStyle = (selectStyles.optionFocused as any)({});
|
|
193
|
+
const optionDisabledStyle = (selectStyles.optionDisabled as any)({});
|
|
194
|
+
const optionContentStyle = (selectStyles.optionContent as any)({});
|
|
195
|
+
const optionIconStyle = (selectStyles.optionIcon as any)({});
|
|
196
|
+
const optionTextStyle = (selectStyles.optionText as any)({});
|
|
197
|
+
const optionTextDisabledStyle = (selectStyles.optionTextDisabled as any)({});
|
|
198
|
+
const helperTextStyle = (selectStyles.helperText as any)({ error });
|
|
182
199
|
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
]);
|
|
200
|
+
const containerWebProps = getWebProps([containerStyle, style as any]);
|
|
201
|
+
const triggerWebProps = getWebProps([triggerStyle]);
|
|
186
202
|
|
|
187
203
|
const handleClose = () => {
|
|
188
204
|
setIsOpen(false);
|
|
@@ -194,7 +210,7 @@ const Select = forwardRef<HTMLDivElement, SelectProps>(({
|
|
|
194
210
|
return (
|
|
195
211
|
<div {...containerWebProps} ref={mergedRef} id={id} data-testid={testID}>
|
|
196
212
|
{label && (
|
|
197
|
-
<label {...getWebProps([
|
|
213
|
+
<label {...getWebProps([labelStyle])}>
|
|
198
214
|
{label}
|
|
199
215
|
</label>
|
|
200
216
|
)}
|
|
@@ -211,15 +227,15 @@ const Select = forwardRef<HTMLDivElement, SelectProps>(({
|
|
|
211
227
|
aria-haspopup="listbox"
|
|
212
228
|
type="button"
|
|
213
229
|
>
|
|
214
|
-
<div {...getWebProps([
|
|
230
|
+
<div {...getWebProps([triggerContentStyle])}>
|
|
215
231
|
{selectedOption?.icon && (
|
|
216
|
-
<span {...getWebProps([
|
|
232
|
+
<span {...getWebProps([iconStyle])}>
|
|
217
233
|
{selectedOption.icon}
|
|
218
234
|
</span>
|
|
219
235
|
)}
|
|
220
236
|
<span
|
|
221
237
|
{...getWebProps([
|
|
222
|
-
selectedOption ?
|
|
238
|
+
selectedOption ? triggerTextStyle : placeholderStyle
|
|
223
239
|
])}
|
|
224
240
|
>
|
|
225
241
|
{selectedOption ? selectedOption.label : placeholder}
|
|
@@ -227,10 +243,10 @@ const Select = forwardRef<HTMLDivElement, SelectProps>(({
|
|
|
227
243
|
</div>
|
|
228
244
|
|
|
229
245
|
<IconSvg
|
|
230
|
-
|
|
246
|
+
name="chevron-down"
|
|
231
247
|
{...getWebProps([
|
|
232
|
-
|
|
233
|
-
isOpen &&
|
|
248
|
+
chevronStyle,
|
|
249
|
+
isOpen && chevronOpenStyle
|
|
234
250
|
])}
|
|
235
251
|
aria-label="chevron-down"
|
|
236
252
|
/>
|
|
@@ -247,7 +263,7 @@ const Select = forwardRef<HTMLDivElement, SelectProps>(({
|
|
|
247
263
|
zIndex={1000}
|
|
248
264
|
>
|
|
249
265
|
<div
|
|
250
|
-
{...getWebProps([
|
|
266
|
+
{...getWebProps([dropdownStyle])}
|
|
251
267
|
style={{
|
|
252
268
|
maxHeight: maxHeight,
|
|
253
269
|
position: 'relative',
|
|
@@ -258,19 +274,19 @@ const Select = forwardRef<HTMLDivElement, SelectProps>(({
|
|
|
258
274
|
role="listbox"
|
|
259
275
|
>
|
|
260
276
|
{searchable && (
|
|
261
|
-
<div {...getWebProps([
|
|
277
|
+
<div {...getWebProps([searchContainerStyle])}>
|
|
262
278
|
<input
|
|
263
279
|
ref={searchInputRef}
|
|
264
280
|
type="text"
|
|
265
281
|
placeholder="Search options..."
|
|
266
282
|
value={searchTerm}
|
|
267
283
|
onChange={handleSearchChange}
|
|
268
|
-
{...getWebProps([
|
|
284
|
+
{...getWebProps([searchInputStyle])}
|
|
269
285
|
/>
|
|
270
286
|
</div>
|
|
271
287
|
)}
|
|
272
288
|
|
|
273
|
-
<div {...getWebProps([
|
|
289
|
+
<div {...getWebProps([optionsListStyle])}>
|
|
274
290
|
{filteredOptions.map((option, index) => {
|
|
275
291
|
const isFocused = index === focusedIndex;
|
|
276
292
|
|
|
@@ -282,20 +298,20 @@ const Select = forwardRef<HTMLDivElement, SelectProps>(({
|
|
|
282
298
|
aria-selected={option.value === value}
|
|
283
299
|
onMouseEnter={() => setFocusedIndex(index)}
|
|
284
300
|
{...getWebProps([
|
|
285
|
-
|
|
286
|
-
isFocused &&
|
|
287
|
-
option.disabled &&
|
|
301
|
+
optionStyle,
|
|
302
|
+
isFocused && optionFocusedStyle,
|
|
303
|
+
option.disabled && optionDisabledStyle,
|
|
288
304
|
])}
|
|
289
305
|
>
|
|
290
|
-
<div {...getWebProps([
|
|
306
|
+
<div {...getWebProps([optionContentStyle])}>
|
|
291
307
|
{option.icon && (
|
|
292
|
-
<span {...getWebProps([
|
|
308
|
+
<span {...getWebProps([optionIconStyle])}>
|
|
293
309
|
{option.icon}
|
|
294
310
|
</span>
|
|
295
311
|
)}
|
|
296
312
|
<span {...getWebProps([
|
|
297
|
-
|
|
298
|
-
option.disabled &&
|
|
313
|
+
optionTextStyle,
|
|
314
|
+
option.disabled && optionTextDisabledStyle
|
|
299
315
|
])}>
|
|
300
316
|
{option.label}
|
|
301
317
|
</span>
|
|
@@ -305,8 +321,8 @@ const Select = forwardRef<HTMLDivElement, SelectProps>(({
|
|
|
305
321
|
})}
|
|
306
322
|
|
|
307
323
|
{filteredOptions.length === 0 && (
|
|
308
|
-
<div {...getWebProps([
|
|
309
|
-
<span {...getWebProps([
|
|
324
|
+
<div {...getWebProps([optionStyle])} style={{ cursor: 'default' }}>
|
|
325
|
+
<span {...getWebProps([optionTextStyle])}>
|
|
310
326
|
No options found
|
|
311
327
|
</span>
|
|
312
328
|
</div>
|
|
@@ -316,11 +332,7 @@ const Select = forwardRef<HTMLDivElement, SelectProps>(({
|
|
|
316
332
|
</PositionedPortal>
|
|
317
333
|
|
|
318
334
|
{helperText && (
|
|
319
|
-
<div
|
|
320
|
-
{...getWebProps([
|
|
321
|
-
selectStyles.helperText,
|
|
322
|
-
])}
|
|
323
|
-
>
|
|
335
|
+
<div {...getWebProps([helperTextStyle])}>
|
|
324
336
|
{helperText}
|
|
325
337
|
</div>
|
|
326
338
|
)}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
import { Theme, StylesheetStyles } from '@idealyst/theme';
|
|
3
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
4
|
+
|
|
5
|
+
type SkeletonShape = 'rectangle' | 'rounded' | 'circle';
|
|
6
|
+
type SkeletonAnimation = 'pulse' | 'wave' | 'none';
|
|
7
|
+
|
|
8
|
+
type SkeletonVariants = {
|
|
9
|
+
shape: SkeletonShape;
|
|
10
|
+
animation: SkeletonAnimation;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type ExpandedSkeletonStyles = StylesheetStyles<keyof SkeletonVariants>;
|
|
14
|
+
export type ExpandedSkeletonGroupStyles = StylesheetStyles<never>;
|
|
15
|
+
|
|
16
|
+
export type SkeletonStylesheet = {
|
|
17
|
+
skeleton: ExpandedSkeletonStyles;
|
|
18
|
+
group: ExpandedSkeletonGroupStyles;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Create shape variants for skeleton
|
|
23
|
+
*/
|
|
24
|
+
function createShapeVariants(theme: Theme) {
|
|
25
|
+
return {
|
|
26
|
+
rectangle: {
|
|
27
|
+
borderRadius: 0,
|
|
28
|
+
},
|
|
29
|
+
rounded: {
|
|
30
|
+
borderRadius: 8,
|
|
31
|
+
},
|
|
32
|
+
circle: {
|
|
33
|
+
borderRadius: 9999,
|
|
34
|
+
},
|
|
35
|
+
} as const;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Style creators for extension support
|
|
39
|
+
function createSkeletonStyles(theme: Theme) {
|
|
40
|
+
return () => ({
|
|
41
|
+
backgroundColor: theme.colors.surface.tertiary,
|
|
42
|
+
overflow: 'hidden' as const,
|
|
43
|
+
variants: {
|
|
44
|
+
shape: createShapeVariants(theme),
|
|
45
|
+
animation: {
|
|
46
|
+
pulse: {},
|
|
47
|
+
wave: {},
|
|
48
|
+
none: {},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
55
|
+
// transform on native cannot resolve function calls to extract variant structures.
|
|
56
|
+
// @ts-ignore - TS language server needs restart to pick up theme structure changes
|
|
57
|
+
export const skeletonStyles = StyleSheet.create((theme: Theme) => {
|
|
58
|
+
// Apply extensions to main visual elements
|
|
59
|
+
|
|
60
|
+
return applyExtensions('Skeleton', theme, {skeleton: createSkeletonStyles(theme),
|
|
61
|
+
// Additional styles (merged from return)
|
|
62
|
+
// Minor utility styles (not extended)
|
|
63
|
+
group: {
|
|
64
|
+
display: 'flex',
|
|
65
|
+
flexDirection: 'column',
|
|
66
|
+
}});
|
|
67
|
+
});
|
|
@@ -1,71 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skeleton styles using defineStyle.
|
|
3
|
+
*/
|
|
1
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
5
|
+
import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
|
|
6
|
+
import type { Theme as BaseTheme } from '@idealyst/theme';
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
// Required: Unistyles must see StyleSheet usage in original source to process this file
|
|
9
|
+
void StyleSheet;
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
animation: SkeletonAnimation;
|
|
11
|
-
}
|
|
11
|
+
// Wrap theme for $iterator support
|
|
12
|
+
type Theme = ThemeStyleWrapper<BaseTheme>;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
type SkeletonShape = 'rectangle' | 'rounded' | 'circle';
|
|
15
|
+
type SkeletonAnimation = 'pulse' | 'wave' | 'none';
|
|
15
16
|
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
17
|
+
export type SkeletonDynamicProps = {
|
|
18
|
+
shape?: SkeletonShape;
|
|
19
|
+
animation?: SkeletonAnimation;
|
|
20
|
+
};
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* Skeleton styles with shape and animation variants.
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
rectangle: {
|
|
27
|
-
borderRadius: 0,
|
|
28
|
-
},
|
|
29
|
-
rounded: {
|
|
30
|
-
borderRadius: 8,
|
|
31
|
-
},
|
|
32
|
-
circle: {
|
|
33
|
-
borderRadius: 9999,
|
|
34
|
-
},
|
|
35
|
-
} as const;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Style creators for extension support
|
|
39
|
-
function createSkeletonStyles(theme: Theme) {
|
|
40
|
-
return () => ({
|
|
25
|
+
export const skeletonStyles = defineStyle('Skeleton', (theme: Theme) => ({
|
|
26
|
+
skeleton: (_props: SkeletonDynamicProps) => ({
|
|
41
27
|
backgroundColor: theme.colors.surface.tertiary,
|
|
42
28
|
overflow: 'hidden' as const,
|
|
43
29
|
variants: {
|
|
44
|
-
shape:
|
|
30
|
+
shape: {
|
|
31
|
+
rectangle: { borderRadius: 0 },
|
|
32
|
+
rounded: { borderRadius: 8 },
|
|
33
|
+
circle: { borderRadius: 9999 },
|
|
34
|
+
},
|
|
45
35
|
animation: {
|
|
46
36
|
pulse: {},
|
|
47
37
|
wave: {},
|
|
48
38
|
none: {},
|
|
49
39
|
},
|
|
50
40
|
},
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
55
|
-
// transform on native cannot resolve function calls to extract variant structures.
|
|
56
|
-
// @ts-ignore - TS language server needs restart to pick up theme structure changes
|
|
57
|
-
export const skeletonStyles = StyleSheet.create((theme: Theme) => {
|
|
58
|
-
// Apply extensions to main visual elements
|
|
59
|
-
const extended = applyExtensions('Skeleton', theme, {
|
|
60
|
-
skeleton: createSkeletonStyles(theme),
|
|
61
|
-
});
|
|
41
|
+
}),
|
|
62
42
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
flexDirection: 'column',
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
});
|
|
43
|
+
group: (_props: {}) => ({
|
|
44
|
+
display: 'flex' as const,
|
|
45
|
+
flexDirection: 'column' as const,
|
|
46
|
+
}),
|
|
47
|
+
}));
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
import { Theme, Size, Styles} from '@idealyst/theme';
|
|
3
|
+
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
+
import {
|
|
5
|
+
buildMarginVariants,
|
|
6
|
+
buildMarginVerticalVariants,
|
|
7
|
+
buildMarginHorizontalVariants,
|
|
8
|
+
} from '../utils/buildViewStyleVariants';
|
|
9
|
+
import { SliderIntentVariant } from './types';
|
|
10
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Create size variants for track
|
|
14
|
+
*/
|
|
15
|
+
function createTrackSizeVariants(theme: Theme) {
|
|
16
|
+
const variants = {} as Record<Size, Styles>;
|
|
17
|
+
for (const sizeKey in theme.sizes.slider) {
|
|
18
|
+
const size = sizeKey as Size;
|
|
19
|
+
variants[size] = {
|
|
20
|
+
height: theme.sizes.slider[size].trackHeight,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return variants;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get filled track color based on intent
|
|
28
|
+
*/
|
|
29
|
+
function getFilledTrackColor(theme: Theme, intent: SliderIntentVariant) {
|
|
30
|
+
return theme.intents[intent].primary;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Create size variants for thumb
|
|
35
|
+
*/
|
|
36
|
+
function createThumbSizeVariants(theme: Theme) {
|
|
37
|
+
return buildSizeVariants(theme, 'slider', (size) => ({
|
|
38
|
+
width: size.thumbSize,
|
|
39
|
+
height: size.thumbSize,
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get thumb border color based on intent
|
|
45
|
+
*/
|
|
46
|
+
function getThumbBorderColor(theme: Theme, intent: SliderIntentVariant) {
|
|
47
|
+
return theme.intents[intent].primary;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Create size variants for thumb icon
|
|
52
|
+
*/
|
|
53
|
+
function createThumbIconSizeVariants(theme: Theme) {
|
|
54
|
+
return buildSizeVariants(theme, 'slider', (size) => ({
|
|
55
|
+
width: size.thumbIconSize,
|
|
56
|
+
height: size.thumbIconSize,
|
|
57
|
+
minWidth: size.thumbIconSize,
|
|
58
|
+
maxWidth: size.thumbIconSize,
|
|
59
|
+
minHeight: size.thumbIconSize,
|
|
60
|
+
maxHeight: size.thumbIconSize,
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get thumb icon color based on intent
|
|
66
|
+
*/
|
|
67
|
+
function getThumbIconColor(theme: Theme, intent: SliderIntentVariant){
|
|
68
|
+
return theme.intents[intent].primary;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Create size variants for mark
|
|
73
|
+
*/
|
|
74
|
+
function createMarkSizeVariants(theme: Theme) {
|
|
75
|
+
return buildSizeVariants(theme, 'slider', (size) => ({
|
|
76
|
+
height: size.markHeight,
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const createFilledTrackStyles = (theme: Theme) => {
|
|
81
|
+
return ({ intent }: { intent: SliderIntentVariant }) => {
|
|
82
|
+
return {
|
|
83
|
+
position: 'absolute',
|
|
84
|
+
height: '100%',
|
|
85
|
+
borderRadius: 9999,
|
|
86
|
+
top: 0,
|
|
87
|
+
left: 0,
|
|
88
|
+
backgroundColor: getFilledTrackColor(theme, intent),
|
|
89
|
+
} as const;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const createThumbStyles = (theme: Theme) => {
|
|
94
|
+
return ({ intent, disabled }: { intent: SliderIntentVariant, disabled: boolean }) => {
|
|
95
|
+
return {
|
|
96
|
+
position: 'absolute',
|
|
97
|
+
backgroundColor: theme.colors.surface.primary,
|
|
98
|
+
borderRadius: 9999,
|
|
99
|
+
borderWidth: 2,
|
|
100
|
+
borderStyle: 'solid',
|
|
101
|
+
borderColor: getThumbBorderColor(theme, intent),
|
|
102
|
+
top: '50%',
|
|
103
|
+
display: 'flex',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
justifyContent: 'center',
|
|
106
|
+
shadowColor: '#000',
|
|
107
|
+
shadowOffset: { width: 0, height: 2 },
|
|
108
|
+
shadowOpacity: 0.2,
|
|
109
|
+
shadowRadius: 4,
|
|
110
|
+
elevation: 2,
|
|
111
|
+
variants: {
|
|
112
|
+
size: createThumbSizeVariants(theme),
|
|
113
|
+
disabled: {
|
|
114
|
+
true: {
|
|
115
|
+
opacity: 0.6,
|
|
116
|
+
_web: {
|
|
117
|
+
cursor: 'not-allowed',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
false: {
|
|
121
|
+
opacity: 1,
|
|
122
|
+
_web: {
|
|
123
|
+
cursor: 'grab',
|
|
124
|
+
_hover: {
|
|
125
|
+
transform: 'translate(-50%, -50%) scale(1.05)',
|
|
126
|
+
},
|
|
127
|
+
_active: {
|
|
128
|
+
cursor: 'grabbing',
|
|
129
|
+
transform: 'translate(-50%, -50%) scale(1.1)',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
_web: {
|
|
136
|
+
boxShadow: '0 2px 4px rgba(0, 0, 0, 0.2)',
|
|
137
|
+
transform: 'translate(-50%, -50%)',
|
|
138
|
+
transition: 'transform 0.15s ease, box-shadow 0.2s ease',
|
|
139
|
+
},
|
|
140
|
+
} as const;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const createThumbIconStyles = (theme: Theme) => {
|
|
145
|
+
return ({ intent }: { intent: SliderIntentVariant }) => {
|
|
146
|
+
return {
|
|
147
|
+
display: 'flex',
|
|
148
|
+
alignItems: 'center',
|
|
149
|
+
justifyContent: 'center',
|
|
150
|
+
flexShrink: 0,
|
|
151
|
+
color: getThumbIconColor(theme, intent),
|
|
152
|
+
variants: {
|
|
153
|
+
size: createThumbIconSizeVariants(theme),
|
|
154
|
+
},
|
|
155
|
+
} as const;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Container style creator for extension support
|
|
160
|
+
function createContainerStyles(theme: Theme) {
|
|
161
|
+
return () => ({
|
|
162
|
+
gap: 4,
|
|
163
|
+
paddingVertical: 8,
|
|
164
|
+
variants: {
|
|
165
|
+
margin: buildMarginVariants(theme),
|
|
166
|
+
marginVertical: buildMarginVerticalVariants(theme),
|
|
167
|
+
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Track style creator for extension support
|
|
173
|
+
function createTrackStyles(theme: Theme) {
|
|
174
|
+
return () => ({
|
|
175
|
+
backgroundColor: theme.colors.surface.tertiary,
|
|
176
|
+
borderRadius: 9999,
|
|
177
|
+
position: 'relative' as const,
|
|
178
|
+
variants: {
|
|
179
|
+
size: createTrackSizeVariants(theme),
|
|
180
|
+
disabled: {
|
|
181
|
+
true: {
|
|
182
|
+
opacity: 0.5,
|
|
183
|
+
_web: { cursor: 'not-allowed' },
|
|
184
|
+
},
|
|
185
|
+
false: {
|
|
186
|
+
opacity: 1,
|
|
187
|
+
_web: { cursor: 'pointer' },
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
} as const,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel transform on native cannot resolve function calls to extract variant structures.
|
|
195
|
+
export const sliderStyles = StyleSheet.create((theme: Theme) => {
|
|
196
|
+
// Apply extensions to main visual elements
|
|
197
|
+
|
|
198
|
+
return applyExtensions('Slider', theme, {container: createContainerStyles(theme),
|
|
199
|
+
track: createTrackStyles(theme),
|
|
200
|
+
filledTrack: createFilledTrackStyles(theme),
|
|
201
|
+
thumb: createThumbStyles(theme),
|
|
202
|
+
thumbIcon: createThumbIconStyles(theme),
|
|
203
|
+
// Additional styles (merged from return)
|
|
204
|
+
// Minor utility styles
|
|
205
|
+
sliderWrapper: {
|
|
206
|
+
position: 'relative',
|
|
207
|
+
paddingVertical: 4,
|
|
208
|
+
},
|
|
209
|
+
thumbActive: {
|
|
210
|
+
_web: {
|
|
211
|
+
transform: 'translate(-50%, -50%) scale(1.1)',
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
valueLabel: {
|
|
215
|
+
fontSize: 12,
|
|
216
|
+
fontWeight: '600',
|
|
217
|
+
color: theme.colors.text.primary,
|
|
218
|
+
textAlign: 'center',
|
|
219
|
+
},
|
|
220
|
+
minMaxLabels: {
|
|
221
|
+
flexDirection: 'row',
|
|
222
|
+
justifyContent: 'space-between',
|
|
223
|
+
marginTop: 4,
|
|
224
|
+
},
|
|
225
|
+
minMaxLabel: {
|
|
226
|
+
fontSize: 12,
|
|
227
|
+
color: theme.colors.text.secondary,
|
|
228
|
+
},
|
|
229
|
+
mark: {
|
|
230
|
+
position: 'absolute',
|
|
231
|
+
width: 2,
|
|
232
|
+
backgroundColor: theme.colors.border.secondary,
|
|
233
|
+
top: '50%',
|
|
234
|
+
variants: {
|
|
235
|
+
size: createMarkSizeVariants(theme),
|
|
236
|
+
},
|
|
237
|
+
_web: {
|
|
238
|
+
transform: 'translate(-50%, -50%)',
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
marks: {
|
|
242
|
+
position: 'absolute',
|
|
243
|
+
width: '100%',
|
|
244
|
+
height: '100%',
|
|
245
|
+
top: 0,
|
|
246
|
+
left: 0,
|
|
247
|
+
},
|
|
248
|
+
markLabel: {
|
|
249
|
+
position: 'absolute',
|
|
250
|
+
fontSize: 10,
|
|
251
|
+
color: theme.colors.text.secondary,
|
|
252
|
+
top: '100%',
|
|
253
|
+
marginTop: 4,
|
|
254
|
+
_web: {
|
|
255
|
+
transform: 'translateX(-50%)',
|
|
256
|
+
whiteSpace: 'nowrap',
|
|
257
|
+
},
|
|
258
|
+
}});
|
|
259
|
+
});
|