@castui/cast-ui 2.0.0 → 3.1.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/README.md +20 -570
- package/dist/components/Button/Button.d.ts +36 -14
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.js +87 -66
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Button/index.d.ts.map +1 -0
- package/dist/components/Button/index.js +2 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Icon/Icon.d.ts +22 -8
- package/dist/components/Icon/Icon.d.ts.map +1 -1
- package/dist/components/Icon/Icon.js +25 -26
- package/dist/components/Icon/Icon.js.map +1 -1
- package/dist/components/Icon/index.d.ts +2 -0
- package/dist/components/Icon/index.d.ts.map +1 -0
- package/dist/components/Icon/index.js +2 -0
- package/dist/components/Icon/index.js.map +1 -0
- package/dist/index.d.ts +4 -51
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -31
- package/dist/index.js.map +1 -1
- package/dist/theme/ThemeContext.d.ts +59 -0
- package/dist/theme/ThemeContext.d.ts.map +1 -0
- package/dist/theme/ThemeContext.js +92 -0
- package/dist/theme/ThemeContext.js.map +1 -0
- package/dist/theme/index.d.ts +3 -6
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +2 -3
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/themes.d.ts +14 -0
- package/dist/theme/themes.d.ts.map +1 -0
- package/dist/theme/themes.js +98 -0
- package/dist/theme/themes.js.map +1 -0
- package/dist/theme/types.d.ts +30 -467
- package/dist/theme/types.d.ts.map +1 -1
- package/dist/theme/types.js +3 -7
- package/dist/theme/types.js.map +1 -1
- package/dist/tokens/colors.d.ts +35 -0
- package/dist/tokens/colors.d.ts.map +1 -0
- package/dist/tokens/colors.js +74 -0
- package/dist/tokens/colors.js.map +1 -0
- package/dist/tokens/index.d.ts +3 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +3 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/typography.d.ts +27 -0
- package/dist/tokens/typography.d.ts.map +1 -0
- package/dist/tokens/typography.js +30 -0
- package/dist/tokens/typography.js.map +1 -0
- package/package.json +2 -7
- package/dist/components/Alert/Alert.d.ts +0 -14
- package/dist/components/Alert/Alert.d.ts.map +0 -1
- package/dist/components/Alert/Alert.js +0 -57
- package/dist/components/Alert/Alert.js.map +0 -1
- package/dist/components/AppBar/AppBar.d.ts +0 -11
- package/dist/components/AppBar/AppBar.d.ts.map +0 -1
- package/dist/components/AppBar/AppBar.js +0 -32
- package/dist/components/AppBar/AppBar.js.map +0 -1
- package/dist/components/Autocomplete/Autocomplete.d.ts +0 -18
- package/dist/components/Autocomplete/Autocomplete.d.ts.map +0 -1
- package/dist/components/Autocomplete/Autocomplete.js +0 -72
- package/dist/components/Autocomplete/Autocomplete.js.map +0 -1
- package/dist/components/Backdrop/Backdrop.d.ts +0 -8
- package/dist/components/Backdrop/Backdrop.d.ts.map +0 -1
- package/dist/components/Backdrop/Backdrop.js +0 -25
- package/dist/components/Backdrop/Backdrop.js.map +0 -1
- package/dist/components/Badge/Badge.d.ts +0 -11
- package/dist/components/Badge/Badge.d.ts.map +0 -1
- package/dist/components/Badge/Badge.js +0 -42
- package/dist/components/Badge/Badge.js.map +0 -1
- package/dist/components/Card/Card.d.ts +0 -20
- package/dist/components/Card/Card.d.ts.map +0 -1
- package/dist/components/Card/Card.js +0 -58
- package/dist/components/Card/Card.js.map +0 -1
- package/dist/components/Checkbox/Checkbox.d.ts +0 -12
- package/dist/components/Checkbox/Checkbox.d.ts.map +0 -1
- package/dist/components/Checkbox/Checkbox.js +0 -39
- package/dist/components/Checkbox/Checkbox.js.map +0 -1
- package/dist/components/Chip/Chip.d.ts +0 -13
- package/dist/components/Chip/Chip.d.ts.map +0 -1
- package/dist/components/Chip/Chip.js +0 -29
- package/dist/components/Chip/Chip.js.map +0 -1
- package/dist/components/Dialog/Dialog.d.ts +0 -15
- package/dist/components/Dialog/Dialog.d.ts.map +0 -1
- package/dist/components/Dialog/Dialog.js +0 -41
- package/dist/components/Dialog/Dialog.js.map +0 -1
- package/dist/components/Divider/Divider.d.ts +0 -6
- package/dist/components/Divider/Divider.d.ts.map +0 -1
- package/dist/components/Divider/Divider.js +0 -25
- package/dist/components/Divider/Divider.js.map +0 -1
- package/dist/components/FAB/FAB.d.ts +0 -14
- package/dist/components/FAB/FAB.d.ts.map +0 -1
- package/dist/components/FAB/FAB.js +0 -55
- package/dist/components/FAB/FAB.js.map +0 -1
- package/dist/components/Link/Link.d.ts +0 -11
- package/dist/components/Link/Link.d.ts.map +0 -1
- package/dist/components/Link/Link.js +0 -26
- package/dist/components/Link/Link.js.map +0 -1
- package/dist/components/Select/Select.d.ts +0 -18
- package/dist/components/Select/Select.d.ts.map +0 -1
- package/dist/components/Select/Select.js +0 -72
- package/dist/components/Select/Select.js.map +0 -1
- package/dist/components/Skeleton/Skeleton.d.ts +0 -11
- package/dist/components/Skeleton/Skeleton.d.ts.map +0 -1
- package/dist/components/Skeleton/Skeleton.js +0 -27
- package/dist/components/Skeleton/Skeleton.js.map +0 -1
- package/dist/components/Snackbar/Snackbar.d.ts +0 -14
- package/dist/components/Snackbar/Snackbar.d.ts.map +0 -1
- package/dist/components/Snackbar/Snackbar.js +0 -40
- package/dist/components/Snackbar/Snackbar.js.map +0 -1
- package/dist/components/SpeedDial/SpeedDial.d.ts +0 -18
- package/dist/components/SpeedDial/SpeedDial.d.ts.map +0 -1
- package/dist/components/SpeedDial/SpeedDial.js +0 -55
- package/dist/components/SpeedDial/SpeedDial.js.map +0 -1
- package/dist/components/Switch/Switch.d.ts +0 -12
- package/dist/components/Switch/Switch.d.ts.map +0 -1
- package/dist/components/Switch/Switch.js +0 -39
- package/dist/components/Switch/Switch.js.map +0 -1
- package/dist/components/Table/Table.d.ts +0 -15
- package/dist/components/Table/Table.d.ts.map +0 -1
- package/dist/components/Table/Table.js +0 -62
- package/dist/components/Table/Table.js.map +0 -1
- package/dist/components/TextField/TextField.d.ts +0 -19
- package/dist/components/TextField/TextField.d.ts.map +0 -1
- package/dist/components/TextField/TextField.js +0 -60
- package/dist/components/TextField/TextField.js.map +0 -1
- package/dist/components/Typography/Typography.d.ts +0 -21
- package/dist/components/Typography/Typography.d.ts.map +0 -1
- package/dist/components/Typography/Typography.js +0 -41
- package/dist/components/Typography/Typography.js.map +0 -1
- package/dist/default.reference.json +0 -421
- package/dist/theme/ThemeProvider.d.ts +0 -34
- package/dist/theme/ThemeProvider.d.ts.map +0 -1
- package/dist/theme/ThemeProvider.js +0 -41
- package/dist/theme/ThemeProvider.js.map +0 -1
- package/dist/theme/createTheme.d.ts +0 -49
- package/dist/theme/createTheme.d.ts.map +0 -1
- package/dist/theme/createTheme.js +0 -85
- package/dist/theme/createTheme.js.map +0 -1
- package/dist/theme/fonts.d.ts +0 -96
- package/dist/theme/fonts.d.ts.map +0 -1
- package/dist/theme/fonts.js +0 -148
- package/dist/theme/fonts.js.map +0 -1
- package/dist/tokens/generated/default.d.ts +0 -3
- package/dist/tokens/generated/default.d.ts.map +0 -1
- package/dist/tokens/generated/default.js +0 -422
- package/dist/tokens/generated/default.js.map +0 -1
- package/dist/tokens/generated/index.d.ts +0 -2
- package/dist/tokens/generated/index.d.ts.map +0 -1
- package/dist/tokens/generated/index.js +0 -3
- package/dist/tokens/generated/index.js.map +0 -1
|
@@ -1,72 +1,93 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { Pressable, Text, } from 'react-native';
|
|
4
|
-
import { useTheme, resolveFont } from '../../theme';
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
// Component
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
2
|
/**
|
|
9
|
-
*
|
|
3
|
+
* Button — the foundational interactive component of Cast UI.
|
|
10
4
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
5
|
+
* Maps 1:1 to the Figma <Button> component:
|
|
6
|
+
* intent → neutral | brand | danger
|
|
7
|
+
* prominence → default | bold | subtle
|
|
8
|
+
* size → small | default | large
|
|
9
|
+
*
|
|
10
|
+
* Spacing tokens come from the density theme (compact/default/comfortable).
|
|
11
|
+
* Colours come from the semantic intent system (constant across densities).
|
|
12
|
+
* Typography uses the label scale (sm/md/lg) matched to the button size.
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
import { useState, useCallback } from 'react';
|
|
15
|
+
import { Pressable, Text, View, Platform, } from 'react-native';
|
|
16
|
+
import { useTheme } from '../../theme';
|
|
17
|
+
import { fontFamily, fontWeight, label, controlTokens } from '../../tokens';
|
|
18
|
+
import { Icon } from '../Icon';
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Constants
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
/** Maps button size → label typography scale */
|
|
23
|
+
const LABEL_SCALE = {
|
|
24
|
+
small: 'sm',
|
|
25
|
+
default: 'md',
|
|
26
|
+
large: 'lg',
|
|
27
|
+
};
|
|
28
|
+
/** Icon size — fixed at 16px per Figma spec, all button sizes. */
|
|
29
|
+
const ICON_SIZE = 16;
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
// Component
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
export function Button({ children, intent = 'neutral', prominence = 'default', size = 'default', disabled = false, leadingIcon, trailingIcon, onPress, style, accessibilityLabel, }) {
|
|
34
|
+
const { components, colors } = useTheme();
|
|
35
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
36
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
37
|
+
// Resolve tokens for current size + density
|
|
38
|
+
const sizeTokens = components.button[size];
|
|
39
|
+
const labelTokens = label[LABEL_SCALE[size]];
|
|
40
|
+
const intentClrs = colors[intent];
|
|
41
|
+
// Resolve colours based on interaction state
|
|
42
|
+
const getStateColors = useCallback((pressed, hovered) => {
|
|
43
|
+
if (disabled) {
|
|
44
|
+
return {
|
|
45
|
+
bg: '#F3F4F6',
|
|
46
|
+
fg: '#9CA3AF',
|
|
47
|
+
border: '#E5E7EB',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (pressed)
|
|
51
|
+
return intentClrs[prominence].active;
|
|
26
52
|
if (hovered)
|
|
27
|
-
return
|
|
28
|
-
return
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
return (_jsx(Pressable, { ...pressableProps, disabled: disabled, style: containerStyle, ...{
|
|
68
|
-
onHoverIn: () => setHovered(true),
|
|
69
|
-
onHoverOut: () => setHovered(false),
|
|
70
|
-
}, accessibilityRole: "button", children: _jsx(Text, { style: textStyle, children: label }) }));
|
|
53
|
+
return intentClrs[prominence].hover;
|
|
54
|
+
return intentClrs[prominence].default;
|
|
55
|
+
}, [disabled, intentClrs, prominence]);
|
|
56
|
+
return (_jsx(Pressable, { onPress: onPress, disabled: disabled, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), onHoverIn: () => setIsHovered(true), onHoverOut: () => setIsHovered(false), accessibilityRole: "button", accessibilityLabel: accessibilityLabel || children, accessibilityState: { disabled }, style: style, children: ({ pressed }) => {
|
|
57
|
+
const stateColors = getStateColors(pressed, isHovered);
|
|
58
|
+
const containerStyle = {
|
|
59
|
+
flexDirection: 'row',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
justifyContent: 'center',
|
|
62
|
+
alignSelf: 'flex-start',
|
|
63
|
+
gap: sizeTokens.gap,
|
|
64
|
+
paddingHorizontal: sizeTokens.paddingX,
|
|
65
|
+
paddingVertical: sizeTokens.paddingY,
|
|
66
|
+
borderRadius: sizeTokens.borderRadius,
|
|
67
|
+
borderWidth: controlTokens.borderWidth,
|
|
68
|
+
borderColor: stateColors.border,
|
|
69
|
+
backgroundColor: stateColors.bg,
|
|
70
|
+
};
|
|
71
|
+
// Web-only: focus ring via CSS outline
|
|
72
|
+
const focusStyle = isFocused && !disabled && Platform.OS === 'web'
|
|
73
|
+
? {
|
|
74
|
+
outlineWidth: sizeTokens.focusRingWidth,
|
|
75
|
+
outlineColor: intentClrs.ringColour,
|
|
76
|
+
outlineStyle: 'solid',
|
|
77
|
+
outlineOffset: sizeTokens.focusRingOffset,
|
|
78
|
+
}
|
|
79
|
+
: {};
|
|
80
|
+
// Resolve icon props — strings become <Icon> with auto-matched colour
|
|
81
|
+
const resolvedLeading = typeof leadingIcon === 'string' ? (_jsx(Icon, { name: leadingIcon, size: ICON_SIZE, color: stateColors.fg })) : (leadingIcon);
|
|
82
|
+
const resolvedTrailing = typeof trailingIcon === 'string' ? (_jsx(Icon, { name: trailingIcon, size: ICON_SIZE, color: stateColors.fg })) : (trailingIcon);
|
|
83
|
+
return (_jsxs(View, { style: [containerStyle, focusStyle], children: [resolvedLeading, _jsx(Text, { style: {
|
|
84
|
+
fontFamily: fontFamily.sans,
|
|
85
|
+
fontWeight: fontWeight.medium,
|
|
86
|
+
fontSize: labelTokens.fontSize,
|
|
87
|
+
lineHeight: labelTokens.lineHeight,
|
|
88
|
+
letterSpacing: labelTokens.letterSpacing,
|
|
89
|
+
color: stateColors.fg,
|
|
90
|
+
}, selectable: false, children: children }), resolvedTrailing] }));
|
|
91
|
+
} }));
|
|
71
92
|
}
|
|
72
93
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;AAEH,OAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EACL,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,QAAQ,GAIT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE5E,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AA+B/B,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,gDAAgD;AAChD,MAAM,WAAW,GAA2C;IAC1D,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;CACZ,CAAC;AAEF,kEAAkE;AAClE,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,UAAU,MAAM,CAAC,EACrB,QAAQ,EACR,MAAM,GAAG,SAAS,EAClB,UAAU,GAAG,SAAS,EACtB,IAAI,GAAG,SAAS,EAChB,QAAQ,GAAG,KAAK,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CAAC,CAAC,CACF,WAAW,CACZ,CAAC;YACJ,MAAM,gBAAgB,GACpB,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,CACjC,KAAC,IAAI,IAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,CAAC,EAAE,GAAI,CACrE,CAAC,CAAC,CAAC,CACF,YAAY,CACb,CAAC;YAEJ,OAAO,CACL,MAAC,IAAI,IAAC,KAAK,EAAE,CAAC,cAAc,EAAE,UAAuB,CAAC,aACnD,eAAe,EAChB,KAAC,IAAI,IACH,KAAK,EAAE;4BACL,UAAU,EAAE,UAAU,CAAC,IAAI;4BAC3B,UAAU,EAAE,UAAU,CAAC,MAAM;4BAC7B,QAAQ,EAAE,WAAW,CAAC,QAAQ;4BAC9B,UAAU,EAAE,WAAW,CAAC,UAAU;4BAClC,aAAa,EAAE,WAAW,CAAC,aAAa;4BACxC,KAAK,EAAE,WAAW,CAAC,EAAE;yBACtB,EACD,UAAU,EAAE,KAAK,YAEhB,QAAQ,GACJ,EACN,gBAAgB,IACZ,CACR,CAAC;QACJ,CAAC,GACS,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqC,MAAM,UAAU,CAAC"}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Icon — renders a Material Symbols Outlined icon by name.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Material Symbols font with ligature rendering.
|
|
5
|
+
* The `name` prop matches Material Symbols names exactly
|
|
6
|
+
* (e.g., "star", "close", "chevron_right", "add").
|
|
7
|
+
*
|
|
8
|
+
* Requires the MaterialSymbolsOutlined font to be loaded:
|
|
9
|
+
* - Web: Google Fonts CSS import
|
|
10
|
+
* - Expo: expo-font
|
|
11
|
+
* - Bare RN: font asset linking
|
|
12
|
+
*/
|
|
13
|
+
import { type TextStyle, type StyleProp } from 'react-native';
|
|
14
|
+
export type IconProps = {
|
|
15
|
+
/** Material Symbols icon name (e.g., "star", "close", "settings"). */
|
|
4
16
|
name: string;
|
|
5
|
-
/** Icon size.
|
|
6
|
-
size?:
|
|
7
|
-
/** Icon
|
|
17
|
+
/** Icon size in pixels. Defaults to 20. */
|
|
18
|
+
size?: number;
|
|
19
|
+
/** Icon colour. Defaults to "#374151" (neutral fg). */
|
|
8
20
|
color?: string;
|
|
9
|
-
|
|
10
|
-
|
|
21
|
+
/** Additional style overrides. */
|
|
22
|
+
style?: StyleProp<TextStyle>;
|
|
23
|
+
};
|
|
24
|
+
export declare function Icon({ name, size, color, style }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
11
25
|
//# sourceMappingURL=Icon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAkB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9E,MAAM,MAAM,SAAS,GAAG;IACtB,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAOF,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,IAAS,EAAE,KAAiB,EAAE,KAAK,EAAE,EAAE,SAAS,2CA6B5E"}
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Text } from 'react-native';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return (_jsx(Text, { style: style, accessibilityRole: "image", accessibilityLabel: name, children: name }));
|
|
2
|
+
import { Text, Platform } from 'react-native';
|
|
3
|
+
const FONT_FAMILY = Platform.select({
|
|
4
|
+
web: '"Material Symbols Outlined", sans-serif',
|
|
5
|
+
default: 'MaterialSymbolsOutlined',
|
|
6
|
+
});
|
|
7
|
+
export function Icon({ name, size = 20, color = '#374151', style }) {
|
|
8
|
+
return (_jsx(Text, { selectable: false, accessibilityElementsHidden: true, importantForAccessibility: "no", style: [
|
|
9
|
+
{
|
|
10
|
+
fontFamily: FONT_FAMILY,
|
|
11
|
+
fontSize: size,
|
|
12
|
+
lineHeight: size,
|
|
13
|
+
color,
|
|
14
|
+
// Prevent ligature text from taking extra space
|
|
15
|
+
width: size,
|
|
16
|
+
height: size,
|
|
17
|
+
textAlign: 'center',
|
|
18
|
+
// Reset any inherited text styles
|
|
19
|
+
fontWeight: '400',
|
|
20
|
+
fontStyle: 'normal',
|
|
21
|
+
letterSpacing: 0,
|
|
22
|
+
textTransform: 'none',
|
|
23
|
+
textDecorationLine: 'none',
|
|
24
|
+
},
|
|
25
|
+
style,
|
|
26
|
+
], children: name }));
|
|
28
27
|
}
|
|
29
28
|
//# sourceMappingURL=Icon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAkC,MAAM,cAAc,CAAC;AAa9E,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC;IAClC,GAAG,EAAE,yCAAyC;IAC9C,OAAO,EAAE,yBAAyB;CACnC,CAAC,CAAC;AAEH,MAAM,UAAU,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,GAAG,SAAS,EAAE,KAAK,EAAa;IAC3E,OAAO,CACL,KAAC,IAAI,IACH,UAAU,EAAE,KAAK,EACjB,2BAA2B,QAC3B,yBAAyB,EAAC,IAAI,EAC9B,KAAK,EAAE;YACL;gBACE,UAAU,EAAE,WAAW;gBACvB,QAAQ,EAAE,IAAI;gBACd,UAAU,EAAE,IAAI;gBAChB,KAAK;gBACL,gDAAgD;gBAChD,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,IAAI;gBACZ,SAAS,EAAE,QAAQ;gBACnB,kCAAkC;gBAClC,UAAU,EAAE,KAAK;gBACjB,SAAS,EAAE,QAAQ;gBACnB,aAAa,EAAE,CAAC;gBAChB,aAAa,EAAE,MAAM;gBACrB,kBAAkB,EAAE,MAAM;aAC3B;YACD,KAAK;SACN,YAEA,IAAI,GACA,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Icon/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Icon/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,QAAQ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,52 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
5
|
-
export type { DeepPartial } from './theme';
|
|
6
|
-
export { getThemeFontFamilies, googleFontsUrl, resolveFont, ANDROID_WEIGHT_SUFFIX } from './theme';
|
|
7
|
-
export { defaultTheme } from './tokens/generated';
|
|
8
|
-
export { Button } from './components/Button/Button';
|
|
9
|
-
export type { ButtonProps, ButtonVariant } from './components/Button/Button';
|
|
10
|
-
export { Card } from './components/Card/Card';
|
|
11
|
-
export type { CardProps } from './components/Card/Card';
|
|
12
|
-
export { Typography } from './components/Typography/Typography';
|
|
13
|
-
export type { TypographyProps, TypographyVariant } from './components/Typography/Typography';
|
|
14
|
-
export { TextField } from './components/TextField/TextField';
|
|
15
|
-
export type { TextFieldProps } from './components/TextField/TextField';
|
|
16
|
-
export { Checkbox } from './components/Checkbox/Checkbox';
|
|
17
|
-
export type { CheckboxProps } from './components/Checkbox/Checkbox';
|
|
18
|
-
export { FAB } from './components/FAB/FAB';
|
|
19
|
-
export type { FABProps, FABVariant } from './components/FAB/FAB';
|
|
20
|
-
export { Autocomplete } from './components/Autocomplete/Autocomplete';
|
|
21
|
-
export type { AutocompleteProps, AutocompleteOption } from './components/Autocomplete/Autocomplete';
|
|
22
|
-
export { Select } from './components/Select/Select';
|
|
23
|
-
export type { SelectProps, SelectOption } from './components/Select/Select';
|
|
24
|
-
export { Switch } from './components/Switch/Switch';
|
|
25
|
-
export type { SwitchProps } from './components/Switch/Switch';
|
|
26
|
-
export { Badge } from './components/Badge/Badge';
|
|
27
|
-
export type { BadgeProps } from './components/Badge/Badge';
|
|
28
|
-
export { Chip } from './components/Chip/Chip';
|
|
29
|
-
export type { ChipProps } from './components/Chip/Chip';
|
|
30
|
-
export { Divider } from './components/Divider/Divider';
|
|
31
|
-
export type { DividerProps } from './components/Divider/Divider';
|
|
32
|
-
export { Icon } from './components/Icon/Icon';
|
|
33
|
-
export type { IconProps, IconSize } from './components/Icon/Icon';
|
|
34
|
-
export { Table } from './components/Table/Table';
|
|
35
|
-
export type { TableProps, TableColumn } from './components/Table/Table';
|
|
36
|
-
export { Alert } from './components/Alert/Alert';
|
|
37
|
-
export type { AlertProps, AlertSeverity } from './components/Alert/Alert';
|
|
38
|
-
export { Backdrop } from './components/Backdrop/Backdrop';
|
|
39
|
-
export type { BackdropProps } from './components/Backdrop/Backdrop';
|
|
40
|
-
export { Skeleton } from './components/Skeleton/Skeleton';
|
|
41
|
-
export type { SkeletonProps, SkeletonVariant } from './components/Skeleton/Skeleton';
|
|
42
|
-
export { Snackbar } from './components/Snackbar/Snackbar';
|
|
43
|
-
export type { SnackbarProps } from './components/Snackbar/Snackbar';
|
|
44
|
-
export { Dialog } from './components/Dialog/Dialog';
|
|
45
|
-
export type { DialogProps } from './components/Dialog/Dialog';
|
|
46
|
-
export { AppBar } from './components/AppBar/AppBar';
|
|
47
|
-
export type { AppBarProps } from './components/AppBar/AppBar';
|
|
48
|
-
export { Link } from './components/Link/Link';
|
|
49
|
-
export type { LinkProps } from './components/Link/Link';
|
|
50
|
-
export { SpeedDial } from './components/SpeedDial/SpeedDial';
|
|
51
|
-
export type { SpeedDialProps, SpeedDialAction } from './components/SpeedDial/SpeedDial';
|
|
1
|
+
export { intentColors, disabledColors, controlTokens, fontFamily, fontWeight, label, type IntentName, type ProminenceName, type StateName, type LabelSize, } from './tokens';
|
|
2
|
+
export { ThemeProvider, useTheme, themes, type Theme, type ThemeProviderProps, type DensityTheme, type ComponentTokens, type ButtonSizeTokens, type ButtonThemeTokens, type DeepPartial, } from './theme';
|
|
3
|
+
export { Button, type ButtonProps, type ButtonSize } from './components/Button';
|
|
4
|
+
export { Icon, type IconProps } from './components/Icon';
|
|
52
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,UAAU,EACV,UAAU,EACV,KAAK,EACL,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,SAAS,GACf,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,aAAa,EACb,QAAQ,EACR,MAAM,EACN,KAAK,KAAK,EACV,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,WAAW,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,10 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
export { getThemeFontFamilies, googleFontsUrl, resolveFont, ANDROID_WEIGHT_SUFFIX } from './theme';
|
|
8
|
-
// Theme objects
|
|
9
|
-
export { defaultTheme } from './tokens/generated';
|
|
1
|
+
// Cast UI — Cross-platform design system component library
|
|
2
|
+
//
|
|
3
|
+
// Tokens
|
|
4
|
+
export { intentColors, disabledColors, controlTokens, fontFamily, fontWeight, label, } from './tokens';
|
|
5
|
+
// Theme
|
|
6
|
+
export { ThemeProvider, useTheme, themes, } from './theme';
|
|
10
7
|
// Components
|
|
11
|
-
export { Button } from './components/Button
|
|
12
|
-
export {
|
|
13
|
-
export { Typography } from './components/Typography/Typography';
|
|
14
|
-
export { TextField } from './components/TextField/TextField';
|
|
15
|
-
export { Checkbox } from './components/Checkbox/Checkbox';
|
|
16
|
-
export { FAB } from './components/FAB/FAB';
|
|
17
|
-
export { Autocomplete } from './components/Autocomplete/Autocomplete';
|
|
18
|
-
export { Select } from './components/Select/Select';
|
|
19
|
-
export { Switch } from './components/Switch/Switch';
|
|
20
|
-
export { Badge } from './components/Badge/Badge';
|
|
21
|
-
export { Chip } from './components/Chip/Chip';
|
|
22
|
-
export { Divider } from './components/Divider/Divider';
|
|
23
|
-
export { Icon } from './components/Icon/Icon';
|
|
24
|
-
export { Table } from './components/Table/Table';
|
|
25
|
-
export { Alert } from './components/Alert/Alert';
|
|
26
|
-
export { Backdrop } from './components/Backdrop/Backdrop';
|
|
27
|
-
export { Skeleton } from './components/Skeleton/Skeleton';
|
|
28
|
-
export { Snackbar } from './components/Snackbar/Snackbar';
|
|
29
|
-
export { Dialog } from './components/Dialog/Dialog';
|
|
30
|
-
export { AppBar } from './components/AppBar/AppBar';
|
|
31
|
-
export { Link } from './components/Link/Link';
|
|
32
|
-
export { SpeedDial } from './components/SpeedDial/SpeedDial';
|
|
8
|
+
export { Button } from './components/Button';
|
|
9
|
+
export { Icon } from './components/Icon';
|
|
33
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,EAAE;AACF,SAAS;AACT,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,UAAU,EACV,UAAU,EACV,KAAK,GAKN,MAAM,UAAU,CAAC;AAElB,QAAQ;AACR,OAAO,EACL,aAAa,EACb,QAAQ,EACR,MAAM,GAQP,MAAM,SAAS,CAAC;AAEjB,aAAa;AACb,OAAO,EAAE,MAAM,EAAqC,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAkB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThemeProvider — wraps your app to enable density theming and colour customisation.
|
|
3
|
+
*
|
|
4
|
+
* @example Basic usage — switch density
|
|
5
|
+
* ```tsx
|
|
6
|
+
* import { ThemeProvider } from '@castui/cast-ui';
|
|
7
|
+
*
|
|
8
|
+
* <ThemeProvider density="comfortable">
|
|
9
|
+
* <App />
|
|
10
|
+
* </ThemeProvider>
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @example Rebrand — override intent colours
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <ThemeProvider
|
|
16
|
+
* density="default"
|
|
17
|
+
* colors={{
|
|
18
|
+
* brand: {
|
|
19
|
+
* bold: {
|
|
20
|
+
* default: { bg: '#7C3AED', fg: '#FFFFFF', border: '#7C3AED' },
|
|
21
|
+
* hover: { bg: '#6D28D9', fg: '#FFFFFF', border: '#6D28D9' },
|
|
22
|
+
* active: { bg: '#5B21B6', fg: '#FFFFFF', border: '#5B21B6' },
|
|
23
|
+
* },
|
|
24
|
+
* },
|
|
25
|
+
* }}
|
|
26
|
+
* >
|
|
27
|
+
* <App />
|
|
28
|
+
* </ThemeProvider>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
import React from 'react';
|
|
32
|
+
import { intentColors as defaultIntentColors, disabledColors as defaultDisabledColors } from '../tokens/colors';
|
|
33
|
+
import type { IntentName } from '../tokens/colors';
|
|
34
|
+
import type { DensityTheme, ComponentTokens, DeepPartial } from './types';
|
|
35
|
+
type IntentColorMap = typeof defaultIntentColors;
|
|
36
|
+
export type Theme = {
|
|
37
|
+
density: DensityTheme;
|
|
38
|
+
components: ComponentTokens;
|
|
39
|
+
colors: IntentColorMap;
|
|
40
|
+
disabledColors: typeof defaultDisabledColors;
|
|
41
|
+
};
|
|
42
|
+
export type ThemeProviderProps = {
|
|
43
|
+
/** Density theme — controls spacing and padding across all components. */
|
|
44
|
+
density?: DensityTheme;
|
|
45
|
+
/**
|
|
46
|
+
* Partial colour overrides — deep-merged with the default intent colours.
|
|
47
|
+
* Only provide the values you want to change; everything else stays default.
|
|
48
|
+
*/
|
|
49
|
+
colors?: Partial<Record<IntentName, DeepPartial<IntentColorMap[IntentName]>>>;
|
|
50
|
+
children: React.ReactNode;
|
|
51
|
+
};
|
|
52
|
+
export declare function ThemeProvider({ density, colors, children, }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
/**
|
|
54
|
+
* Access the current theme — density tokens, intent colours, and component tokens.
|
|
55
|
+
* Must be called within a ThemeProvider; falls back to the "default" density if not.
|
|
56
|
+
*/
|
|
57
|
+
export declare function useTheme(): Theme;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=ThemeContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeContext.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAA6C,MAAM,OAAO,CAAC;AAElE,OAAO,EACL,YAAY,IAAI,mBAAmB,EACnC,cAAc,IAAI,qBAAqB,EACxC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAM1E,KAAK,cAAc,GAAG,OAAO,mBAAmB,CAAC;AAEjD,MAAM,MAAM,KAAK,GAAG;IAClB,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,eAAe,CAAC;IAC5B,MAAM,EAAE,cAAc,CAAC;IACvB,cAAc,EAAE,OAAO,qBAAqB,CAAC;CAC9C,CAAC;AAkDF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,0EAA0E;IAC1E,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAC5B,OAAmB,EACnB,MAAM,EACN,QAAQ,GACT,EAAE,kBAAkB,2CAiBpB;AAMD;;;GAGG;AACH,wBAAgB,QAAQ,IAAI,KAAK,CAEhC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* ThemeProvider — wraps your app to enable density theming and colour customisation.
|
|
4
|
+
*
|
|
5
|
+
* @example Basic usage — switch density
|
|
6
|
+
* ```tsx
|
|
7
|
+
* import { ThemeProvider } from '@castui/cast-ui';
|
|
8
|
+
*
|
|
9
|
+
* <ThemeProvider density="comfortable">
|
|
10
|
+
* <App />
|
|
11
|
+
* </ThemeProvider>
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @example Rebrand — override intent colours
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <ThemeProvider
|
|
17
|
+
* density="default"
|
|
18
|
+
* colors={{
|
|
19
|
+
* brand: {
|
|
20
|
+
* bold: {
|
|
21
|
+
* default: { bg: '#7C3AED', fg: '#FFFFFF', border: '#7C3AED' },
|
|
22
|
+
* hover: { bg: '#6D28D9', fg: '#FFFFFF', border: '#6D28D9' },
|
|
23
|
+
* active: { bg: '#5B21B6', fg: '#FFFFFF', border: '#5B21B6' },
|
|
24
|
+
* },
|
|
25
|
+
* },
|
|
26
|
+
* }}
|
|
27
|
+
* >
|
|
28
|
+
* <App />
|
|
29
|
+
* </ThemeProvider>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
33
|
+
import { themes } from './themes';
|
|
34
|
+
import { intentColors as defaultIntentColors, disabledColors as defaultDisabledColors, } from '../tokens/colors';
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Deep merge utility (for partial colour overrides)
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
function deepMerge(base, overrides) {
|
|
39
|
+
const result = { ...base };
|
|
40
|
+
for (const key of Object.keys(overrides)) {
|
|
41
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype')
|
|
42
|
+
continue;
|
|
43
|
+
const baseVal = base[key];
|
|
44
|
+
const overVal = overrides[key];
|
|
45
|
+
if (overVal &&
|
|
46
|
+
typeof overVal === 'object' &&
|
|
47
|
+
!Array.isArray(overVal) &&
|
|
48
|
+
baseVal &&
|
|
49
|
+
typeof baseVal === 'object') {
|
|
50
|
+
result[key] = deepMerge(baseVal, overVal);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
result[key] = overVal;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Context
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
const defaultTheme = {
|
|
62
|
+
density: 'default',
|
|
63
|
+
components: themes.default,
|
|
64
|
+
colors: defaultIntentColors,
|
|
65
|
+
disabledColors: defaultDisabledColors,
|
|
66
|
+
};
|
|
67
|
+
const ThemeContext = createContext(defaultTheme);
|
|
68
|
+
export function ThemeProvider({ density = 'default', colors, children, }) {
|
|
69
|
+
const theme = useMemo(() => {
|
|
70
|
+
const resolvedColors = colors
|
|
71
|
+
? deepMerge(defaultIntentColors, colors)
|
|
72
|
+
: defaultIntentColors;
|
|
73
|
+
return {
|
|
74
|
+
density,
|
|
75
|
+
components: themes[density],
|
|
76
|
+
colors: resolvedColors,
|
|
77
|
+
disabledColors: defaultDisabledColors,
|
|
78
|
+
};
|
|
79
|
+
}, [density, colors]);
|
|
80
|
+
return (_jsx(ThemeContext.Provider, { value: theme, children: children }));
|
|
81
|
+
}
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Hook
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
/**
|
|
86
|
+
* Access the current theme — density tokens, intent colours, and component tokens.
|
|
87
|
+
* Must be called within a ThemeProvider; falls back to the "default" density if not.
|
|
88
|
+
*/
|
|
89
|
+
export function useTheme() {
|
|
90
|
+
return useContext(ThemeContext);
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=ThemeContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeContext.js","sourceRoot":"","sources":["../../src/theme/ThemeContext.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EACL,YAAY,IAAI,mBAAmB,EACnC,cAAc,IAAI,qBAAqB,GACxC,MAAM,kBAAkB,CAAC;AAiB1B,8EAA8E;AAC9E,oDAAoD;AACpD,8EAA8E;AAE9E,SAAS,SAAS,CAChB,IAAO,EACP,SAAkC;IAElC,MAAM,MAAM,GAA4B,EAAE,GAAG,IAAI,EAAE,CAAC;IACpD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACzC,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,aAAa,IAAI,GA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