@cdx-ui/components 0.3.2 → 0.3.4
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 +2 -2
- package/coverage.svg +1 -1
- package/docs/components/color-field/content.md +2 -2
- package/docs/components/content.md +6 -4
- package/docs/components/data-grid/content.md +125 -1
- package/docs/components/date-field/content.md +2 -2
- package/docs/components/date-time-field/content.md +2 -2
- package/docs/components/input/content.md +20 -2
- package/docs/components/input/design.md +1 -1
- package/docs/components/insight/content.md +644 -0
- package/docs/components/insight-stack/content.md +231 -0
- package/docs/components/insurance-disclosure/content.md +1 -1
- package/docs/components/otp-input/content.md +2 -2
- package/docs/components/select/content.md +223 -24
- package/docs/components/text/content.md +97 -0
- package/docs/foundations/styles/tokens/all-tokens/content.md +23 -3
- package/docs/llms.txt +8 -4
- package/docs/patterns/forms/content.md +407 -0
- package/docs/resources/release-notes/0.3.2/content.md +17 -0
- package/docs/resources/release-notes/0.3.3/content.md +23 -0
- package/docs/resources/release-notes/content.md +2 -0
- package/lib/commonjs/components/Drawer/index.js +1 -1
- package/lib/commonjs/components/Drawer/index.js.map +1 -1
- package/lib/commonjs/components/Input/index.js.map +1 -1
- package/lib/commonjs/components/Input/styles.js +13 -6
- package/lib/commonjs/components/Input/styles.js.map +1 -1
- package/lib/commonjs/components/Insight/index.js +438 -0
- package/lib/commonjs/components/Insight/index.js.map +1 -0
- package/lib/commonjs/components/Insight/insetRadius.js +35 -0
- package/lib/commonjs/components/Insight/insetRadius.js.map +1 -0
- package/lib/commonjs/components/Insight/styles.js +186 -0
- package/lib/commonjs/components/Insight/styles.js.map +1 -0
- package/lib/commonjs/components/InsightStack/index.js +93 -0
- package/lib/commonjs/components/InsightStack/index.js.map +1 -0
- package/lib/commonjs/components/InsightStack/styles.js +61 -0
- package/lib/commonjs/components/InsightStack/styles.js.map +1 -0
- package/lib/commonjs/components/OtpInput/index.js.map +1 -1
- package/lib/commonjs/components/Select/index.js +326 -24
- package/lib/commonjs/components/Select/index.js.map +1 -1
- package/lib/commonjs/components/Select/styles.js +32 -1
- package/lib/commonjs/components/Select/styles.js.map +1 -1
- package/lib/commonjs/components/index.js +24 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/picker/surfaces.js +18 -3
- package/lib/commonjs/components/picker/surfaces.js.map +1 -1
- package/lib/commonjs/figma/Insight.figma.js +73 -0
- package/lib/commonjs/figma/Insight.figma.js.map +1 -0
- package/lib/commonjs/figma/InsightStack.figma.js +39 -0
- package/lib/commonjs/figma/InsightStack.figma.js.map +1 -0
- package/lib/module/components/Drawer/index.js +1 -1
- package/lib/module/components/Drawer/index.js.map +1 -1
- package/lib/module/components/Input/index.js.map +1 -1
- package/lib/module/components/Input/styles.js +14 -6
- package/lib/module/components/Input/styles.js.map +1 -1
- package/lib/module/components/Insight/index.js +433 -0
- package/lib/module/components/Insight/index.js.map +1 -0
- package/lib/module/components/Insight/insetRadius.js +30 -0
- package/lib/module/components/Insight/insetRadius.js.map +1 -0
- package/lib/module/components/Insight/styles.js +183 -0
- package/lib/module/components/Insight/styles.js.map +1 -0
- package/lib/module/components/InsightStack/index.js +89 -0
- package/lib/module/components/InsightStack/index.js.map +1 -0
- package/lib/module/components/InsightStack/styles.js +58 -0
- package/lib/module/components/InsightStack/styles.js.map +1 -0
- package/lib/module/components/OtpInput/index.js.map +1 -1
- package/lib/module/components/Select/index.js +328 -26
- package/lib/module/components/Select/index.js.map +1 -1
- package/lib/module/components/Select/styles.js +31 -0
- package/lib/module/components/Select/styles.js.map +1 -1
- package/lib/module/components/index.js +2 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/picker/surfaces.js +17 -3
- package/lib/module/components/picker/surfaces.js.map +1 -1
- package/lib/module/figma/Insight.figma.js +67 -0
- package/lib/module/figma/Insight.figma.js.map +1 -0
- package/lib/module/figma/InsightStack.figma.js +33 -0
- package/lib/module/figma/InsightStack.figma.js.map +1 -0
- package/lib/typescript/components/ColorField/styles.d.ts +4 -2
- package/lib/typescript/components/ColorField/styles.d.ts.map +1 -1
- package/lib/typescript/components/DateField/styles.d.ts +4 -2
- package/lib/typescript/components/DateField/styles.d.ts.map +1 -1
- package/lib/typescript/components/Input/index.d.ts +3 -2
- package/lib/typescript/components/Input/index.d.ts.map +1 -1
- package/lib/typescript/components/Input/styles.d.ts +1 -1
- package/lib/typescript/components/Input/styles.d.ts.map +1 -1
- package/lib/typescript/components/Insight/index.d.ts +87 -0
- package/lib/typescript/components/Insight/index.d.ts.map +1 -0
- package/lib/typescript/components/Insight/insetRadius.d.ts +8 -0
- package/lib/typescript/components/Insight/insetRadius.d.ts.map +1 -0
- package/lib/typescript/components/Insight/styles.d.ts +33 -0
- package/lib/typescript/components/Insight/styles.d.ts.map +1 -0
- package/lib/typescript/components/InsightStack/index.d.ts +21 -0
- package/lib/typescript/components/InsightStack/index.d.ts.map +1 -0
- package/lib/typescript/components/InsightStack/styles.d.ts +11 -0
- package/lib/typescript/components/InsightStack/styles.d.ts.map +1 -0
- package/lib/typescript/components/OtpInput/index.d.ts +3 -2
- package/lib/typescript/components/OtpInput/index.d.ts.map +1 -1
- package/lib/typescript/components/Select/index.d.ts +73 -6
- package/lib/typescript/components/Select/index.d.ts.map +1 -1
- package/lib/typescript/components/Select/styles.d.ts +9 -0
- package/lib/typescript/components/Select/styles.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +2 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/components/picker/surfaces.d.ts +14 -3
- package/lib/typescript/components/picker/surfaces.d.ts.map +1 -1
- package/lib/typescript/figma/Insight.figma.d.ts +8 -0
- package/lib/typescript/figma/Insight.figma.d.ts.map +1 -0
- package/lib/typescript/figma/InsightStack.figma.d.ts +8 -0
- package/lib/typescript/figma/InsightStack.figma.d.ts.map +1 -0
- package/package.json +5 -5
- package/src/components/ColorField/styles.ts +3 -1
- package/src/components/DateField/styles.ts +6 -1
- package/src/components/Drawer/index.tsx +1 -1
- package/src/components/Input/index.tsx +3 -2
- package/src/components/Input/styles.ts +35 -15
- package/src/components/Insight/index.tsx +531 -0
- package/src/components/Insight/insetRadius.ts +30 -0
- package/src/components/Insight/styles.ts +193 -0
- package/src/components/InsightStack/index.tsx +86 -0
- package/src/components/InsightStack/styles.ts +61 -0
- package/src/components/OtpInput/index.tsx +3 -2
- package/src/components/Select/index.tsx +411 -29
- package/src/components/Select/styles.ts +36 -0
- package/src/components/index.ts +2 -0
- package/src/components/picker/surfaces.tsx +29 -4
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { cloneElement, forwardRef, isValidElement, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { Platform, Text, View } from 'react-native';
|
|
5
|
+
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
6
|
+
import { useCSSVariable } from 'uniwind';
|
|
7
|
+
import { InsightRoot, Slot, dataAttributes, mergeDataAttributes, useInsightContext } from '@cdx-ui/primitives';
|
|
8
|
+
import { Close, Sparkle } from '@cdx-ui/icons';
|
|
9
|
+
import { cn, createContext, ParentContext, useParentContext, useStyleContext } from '@cdx-ui/utils';
|
|
10
|
+
import { Avatar } from '../Avatar';
|
|
11
|
+
import { Chip } from '../Chip';
|
|
12
|
+
import { IconButton } from '../IconButton';
|
|
13
|
+
import { useCombinedAnimationDisabledState } from '../../animation';
|
|
14
|
+
import { insetRadius } from './insetRadius';
|
|
15
|
+
import { FRAME_WIDTH, insightCloseVariants, insightContentVariants, insightDescriptionVariants, insightFooterVariants, insightFrameVariants, insightHeaderVariants, insightIconVariants, insightPressRegionVariants, insightSummaryTextVariants, insightSurfaceVariants, insightTagIconVariants, insightTagVariants, insightTitleVariants } from './styles';
|
|
16
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
const SCOPE = 'INSIGHT';
|
|
18
|
+
const useInsightStyleContext = () => useStyleContext(SCOPE);
|
|
19
|
+
const [InsightTagRegistryProvider, useInsightTagRegistry] = createContext('InsightTagRegistry');
|
|
20
|
+
let hasWarnedMissingTag = false;
|
|
21
|
+
const PRESSED_SCALE = 0.98;
|
|
22
|
+
const PRESS_SCALE_DURATION_MS = 120;
|
|
23
|
+
|
|
24
|
+
// =============================================================================
|
|
25
|
+
// ROOT
|
|
26
|
+
// =============================================================================
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* `className` and `style` style the outer frame (the border). `asChild` replaces the inner
|
|
30
|
+
* surface element. `onPress` exists only on `layout="summary"`.
|
|
31
|
+
*
|
|
32
|
+
* `ref` targets the element that takes focus: the press region of a summary with `onPress`
|
|
33
|
+
* (the surface, or the region beside the dismiss button when `onClose` is also set), so
|
|
34
|
+
* `ref.current?.focus()` moves focus to the card. A static Insight puts `ref` on its surface.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Press state lives in InsightRoot's context, but the scaled element is the frame around it, so
|
|
39
|
+
* this child of the root writes the frame's shared value.
|
|
40
|
+
*/
|
|
41
|
+
function InsightPressScale({
|
|
42
|
+
scale
|
|
43
|
+
}) {
|
|
44
|
+
const {
|
|
45
|
+
isPressed,
|
|
46
|
+
isPressable
|
|
47
|
+
} = useInsightContext();
|
|
48
|
+
const isAllAnimationsDisabled = useCombinedAnimationDisabledState(undefined);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!isPressable || isAllAnimationsDisabled) {
|
|
51
|
+
scale.set(1);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
scale.set(withTiming(isPressed ? PRESSED_SCALE : 1, {
|
|
55
|
+
duration: PRESS_SCALE_DURATION_MS
|
|
56
|
+
}));
|
|
57
|
+
}, [scale, isPressed, isPressable, isAllAnimationsDisabled]);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
function SummaryBody({
|
|
61
|
+
hasClose,
|
|
62
|
+
scale,
|
|
63
|
+
children
|
|
64
|
+
}) {
|
|
65
|
+
const {
|
|
66
|
+
color
|
|
67
|
+
} = useInsightStyleContext();
|
|
68
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
69
|
+
children: [/*#__PURE__*/_jsx(InsightPressScale, {
|
|
70
|
+
scale: scale
|
|
71
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
72
|
+
"aria-hidden": true,
|
|
73
|
+
accessibilityElementsHidden: true,
|
|
74
|
+
importantForAccessibility: "no-hide-descendants",
|
|
75
|
+
...dataAttributes({
|
|
76
|
+
slot: 'insight-icon'
|
|
77
|
+
}),
|
|
78
|
+
children: /*#__PURE__*/_jsx(Avatar, {
|
|
79
|
+
size: "md",
|
|
80
|
+
variant: "subtle",
|
|
81
|
+
color: color,
|
|
82
|
+
children: /*#__PURE__*/_jsx(Avatar.Icon, {
|
|
83
|
+
as: Sparkle,
|
|
84
|
+
className: insightIconVariants({
|
|
85
|
+
color
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
90
|
+
className: insightSummaryTextVariants({
|
|
91
|
+
hasClose
|
|
92
|
+
}),
|
|
93
|
+
children: children
|
|
94
|
+
})]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const InsightRootStyled = /*#__PURE__*/forwardRef((props, ref) => {
|
|
98
|
+
const {
|
|
99
|
+
color = 'info',
|
|
100
|
+
aiGenerated = false,
|
|
101
|
+
onClose,
|
|
102
|
+
closeAccessibilityLabel = 'Dismiss insight',
|
|
103
|
+
asChild = false,
|
|
104
|
+
className,
|
|
105
|
+
style,
|
|
106
|
+
children,
|
|
107
|
+
...rootProps
|
|
108
|
+
} = props;
|
|
109
|
+
const layout = props.layout ?? 'summary';
|
|
110
|
+
const onPress = props.layout !== 'detail' ? props.onPress : undefined;
|
|
111
|
+
const isDisabled = props.layout !== 'detail' && !!props.isDisabled;
|
|
112
|
+
const hasClose = !!onClose;
|
|
113
|
+
const asChildElement = asChild && /*#__PURE__*/isValidElement(children);
|
|
114
|
+
const isPressable = layout === 'summary' && !!onPress;
|
|
115
|
+
// Mirrors InsightRoot: an accessory splits a pressable or `asChild` root into a container
|
|
116
|
+
// and a press region.
|
|
117
|
+
const isSplit = hasClose && (isPressable || asChildElement);
|
|
118
|
+
|
|
119
|
+
// The frame scales, not the press region, so the border and the close button move with it.
|
|
120
|
+
const scale = useSharedValue(1);
|
|
121
|
+
// Explicit deps for Vite/web without the Reanimated Babel plugin.
|
|
122
|
+
const pressScaleStyle = useAnimatedStyle(() => ({
|
|
123
|
+
transform: [{
|
|
124
|
+
scale: scale.get()
|
|
125
|
+
}]
|
|
126
|
+
}), [scale]);
|
|
127
|
+
const [tag, setTag] = useState(null);
|
|
128
|
+
const tagOwnerRef = useRef(null);
|
|
129
|
+
const registerTag = useCallback((owner, next) => {
|
|
130
|
+
if (next) {
|
|
131
|
+
tagOwnerRef.current = owner;
|
|
132
|
+
setTag(next);
|
|
133
|
+
} else if (tagOwnerRef.current === owner) {
|
|
134
|
+
tagOwnerRef.current = null;
|
|
135
|
+
setTag(null);
|
|
136
|
+
}
|
|
137
|
+
}, []);
|
|
138
|
+
const registry = useMemo(() => ({
|
|
139
|
+
registerTag
|
|
140
|
+
}), [registerTag]);
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (__DEV__ && layout === 'detail' && tagOwnerRef.current === null && !hasWarnedMissingTag) {
|
|
143
|
+
hasWarnedMissingTag = true;
|
|
144
|
+
console.warn('[Insight] A `layout="detail"` Insight needs an `Insight.Tag` child. The design has no tagless detail layout.');
|
|
145
|
+
}
|
|
146
|
+
}, [layout]);
|
|
147
|
+
|
|
148
|
+
// A runtime override reaches native as a `px` string, which a `calc()` class turns into NaN.
|
|
149
|
+
// Web keeps the `calc()` class, which tracks the root font size and scoped overrides.
|
|
150
|
+
const radiusVariable = useCSSVariable('--border-radius-default');
|
|
151
|
+
const surfaceRadius = Platform.OS === 'web' ? undefined : insetRadius(radiusVariable, FRAME_WIDTH);
|
|
152
|
+
const surfaceStyle = useMemo(() => surfaceRadius === undefined ? undefined : {
|
|
153
|
+
borderRadius: surfaceRadius
|
|
154
|
+
}, [surfaceRadius]);
|
|
155
|
+
const parent = useParentContext();
|
|
156
|
+
const ctx = useMemo(() => ({
|
|
157
|
+
...parent,
|
|
158
|
+
[SCOPE]: {
|
|
159
|
+
layout,
|
|
160
|
+
color,
|
|
161
|
+
hasClose
|
|
162
|
+
}
|
|
163
|
+
}), [parent, layout, color, hasClose]);
|
|
164
|
+
let content = children;
|
|
165
|
+
if (layout === 'summary') {
|
|
166
|
+
content = asChildElement ? (/*#__PURE__*/cloneElement(children, undefined, /*#__PURE__*/_jsx(SummaryBody, {
|
|
167
|
+
hasClose: hasClose,
|
|
168
|
+
scale: scale,
|
|
169
|
+
children: children.props.children
|
|
170
|
+
}))) : /*#__PURE__*/_jsx(SummaryBody, {
|
|
171
|
+
hasClose: hasClose,
|
|
172
|
+
scale: scale,
|
|
173
|
+
children: children
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
const closeButton = onClose ? /*#__PURE__*/_jsx(IconButton, {
|
|
177
|
+
as: Close,
|
|
178
|
+
variant: "ghost",
|
|
179
|
+
size: "small",
|
|
180
|
+
color: "neutral",
|
|
181
|
+
onPress: onClose,
|
|
182
|
+
accessibilityLabel: closeAccessibilityLabel,
|
|
183
|
+
className: insightCloseVariants(),
|
|
184
|
+
...dataAttributes({
|
|
185
|
+
slot: 'insight-close'
|
|
186
|
+
})
|
|
187
|
+
}) : undefined;
|
|
188
|
+
return /*#__PURE__*/_jsx(ParentContext.Provider, {
|
|
189
|
+
value: ctx,
|
|
190
|
+
children: /*#__PURE__*/_jsx(InsightTagRegistryProvider, {
|
|
191
|
+
value: registry,
|
|
192
|
+
children: /*#__PURE__*/_jsxs(Animated.View, {
|
|
193
|
+
className: cn(insightFrameVariants({
|
|
194
|
+
layout,
|
|
195
|
+
color,
|
|
196
|
+
aiGenerated
|
|
197
|
+
}), className),
|
|
198
|
+
style: isPressable ? [style, pressScaleStyle] : style,
|
|
199
|
+
...dataAttributes({
|
|
200
|
+
slot: 'insight-frame',
|
|
201
|
+
...(isPressable && {
|
|
202
|
+
disabled: isDisabled
|
|
203
|
+
})
|
|
204
|
+
}),
|
|
205
|
+
children: [layout === 'detail' && tag ? /*#__PURE__*/_jsx(InsightTagChip, {
|
|
206
|
+
...tag
|
|
207
|
+
}) : null, /*#__PURE__*/_jsx(InsightRoot, {
|
|
208
|
+
...rootProps,
|
|
209
|
+
ref: ref,
|
|
210
|
+
asChild: asChild,
|
|
211
|
+
style: surfaceStyle,
|
|
212
|
+
accessory: closeButton,
|
|
213
|
+
className: insightSurfaceVariants({
|
|
214
|
+
layout,
|
|
215
|
+
split: isSplit
|
|
216
|
+
}),
|
|
217
|
+
pressableClassName: isSplit && layout === 'summary' ? insightPressRegionVariants() : undefined,
|
|
218
|
+
...mergeDataAttributes(rootProps, dataAttributes({
|
|
219
|
+
slot: 'insight'
|
|
220
|
+
})),
|
|
221
|
+
children: content
|
|
222
|
+
})]
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
InsightRootStyled.displayName = 'Insight';
|
|
228
|
+
|
|
229
|
+
// =============================================================================
|
|
230
|
+
// TAG
|
|
231
|
+
// =============================================================================
|
|
232
|
+
|
|
233
|
+
function InsightTagChip({
|
|
234
|
+
asChild,
|
|
235
|
+
className,
|
|
236
|
+
style,
|
|
237
|
+
children,
|
|
238
|
+
ref,
|
|
239
|
+
...props
|
|
240
|
+
}) {
|
|
241
|
+
const {
|
|
242
|
+
color
|
|
243
|
+
} = useInsightStyleContext();
|
|
244
|
+
return /*#__PURE__*/_jsx(View, {
|
|
245
|
+
ref: ref,
|
|
246
|
+
className: cn(insightTagVariants(), className),
|
|
247
|
+
style: style,
|
|
248
|
+
...props,
|
|
249
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
250
|
+
slot: 'insight-tag'
|
|
251
|
+
})),
|
|
252
|
+
children: /*#__PURE__*/_jsxs(Chip, {
|
|
253
|
+
variant: "subtle",
|
|
254
|
+
size: "small",
|
|
255
|
+
color: color,
|
|
256
|
+
children: [/*#__PURE__*/_jsx(Chip.Icon, {
|
|
257
|
+
as: Sparkle,
|
|
258
|
+
position: "leading",
|
|
259
|
+
className: insightTagIconVariants({
|
|
260
|
+
color
|
|
261
|
+
})
|
|
262
|
+
}), /*#__PURE__*/_jsx(Chip.Label, {
|
|
263
|
+
asChild: asChild,
|
|
264
|
+
children: children
|
|
265
|
+
})]
|
|
266
|
+
})
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* The detail layout's category tag. Insight renders it as a Sparkle chip straddling the top
|
|
272
|
+
* border, ahead of the header in reading order, wherever it appears among the children.
|
|
273
|
+
*/
|
|
274
|
+
const InsightTag = /*#__PURE__*/forwardRef((props, ref) => {
|
|
275
|
+
const {
|
|
276
|
+
registerTag
|
|
277
|
+
} = useInsightTagRegistry();
|
|
278
|
+
const [owner] = useState(() => ({}));
|
|
279
|
+
useLayoutEffect(() => {
|
|
280
|
+
registerTag(owner, {
|
|
281
|
+
...props,
|
|
282
|
+
ref
|
|
283
|
+
});
|
|
284
|
+
}, [registerTag, owner, props, ref]);
|
|
285
|
+
useLayoutEffect(() => () => registerTag(owner, null), [registerTag, owner]);
|
|
286
|
+
return null;
|
|
287
|
+
});
|
|
288
|
+
InsightTag.displayName = 'Insight.Tag';
|
|
289
|
+
|
|
290
|
+
// =============================================================================
|
|
291
|
+
// HEADER
|
|
292
|
+
// =============================================================================
|
|
293
|
+
|
|
294
|
+
const InsightHeader = /*#__PURE__*/forwardRef(({
|
|
295
|
+
asChild,
|
|
296
|
+
className,
|
|
297
|
+
children,
|
|
298
|
+
style,
|
|
299
|
+
...props
|
|
300
|
+
}, ref) => {
|
|
301
|
+
const Comp = asChild ? Slot : View;
|
|
302
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
303
|
+
ref: ref,
|
|
304
|
+
className: cn(insightHeaderVariants(), className),
|
|
305
|
+
style: style,
|
|
306
|
+
...props,
|
|
307
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
308
|
+
slot: 'insight-header'
|
|
309
|
+
})),
|
|
310
|
+
children: children
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
InsightHeader.displayName = 'Insight.Header';
|
|
314
|
+
|
|
315
|
+
// =============================================================================
|
|
316
|
+
// TITLE
|
|
317
|
+
// =============================================================================
|
|
318
|
+
|
|
319
|
+
const InsightTitle = /*#__PURE__*/forwardRef(({
|
|
320
|
+
asChild,
|
|
321
|
+
className,
|
|
322
|
+
children,
|
|
323
|
+
style,
|
|
324
|
+
...props
|
|
325
|
+
}, ref) => {
|
|
326
|
+
const {
|
|
327
|
+
hasClose
|
|
328
|
+
} = useInsightStyleContext();
|
|
329
|
+
const Comp = asChild ? Slot : Text;
|
|
330
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
331
|
+
ref: ref,
|
|
332
|
+
role: "heading",
|
|
333
|
+
className: cn(insightTitleVariants({
|
|
334
|
+
hasClose
|
|
335
|
+
}), className),
|
|
336
|
+
style: style,
|
|
337
|
+
...props,
|
|
338
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
339
|
+
slot: 'insight-title'
|
|
340
|
+
})),
|
|
341
|
+
children: children
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
InsightTitle.displayName = 'Insight.Title';
|
|
345
|
+
|
|
346
|
+
// =============================================================================
|
|
347
|
+
// DESCRIPTION
|
|
348
|
+
// =============================================================================
|
|
349
|
+
|
|
350
|
+
const InsightDescription = /*#__PURE__*/forwardRef(({
|
|
351
|
+
asChild,
|
|
352
|
+
className,
|
|
353
|
+
children,
|
|
354
|
+
style,
|
|
355
|
+
...props
|
|
356
|
+
}, ref) => {
|
|
357
|
+
const Comp = asChild ? Slot : Text;
|
|
358
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
359
|
+
ref: ref,
|
|
360
|
+
className: cn(insightDescriptionVariants(), className),
|
|
361
|
+
style: style,
|
|
362
|
+
...props,
|
|
363
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
364
|
+
slot: 'insight-description'
|
|
365
|
+
})),
|
|
366
|
+
children: children
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
InsightDescription.displayName = 'Insight.Description';
|
|
370
|
+
|
|
371
|
+
// =============================================================================
|
|
372
|
+
// CONTENT
|
|
373
|
+
// =============================================================================
|
|
374
|
+
|
|
375
|
+
const InsightContent = /*#__PURE__*/forwardRef(({
|
|
376
|
+
asChild,
|
|
377
|
+
className,
|
|
378
|
+
children,
|
|
379
|
+
style,
|
|
380
|
+
...props
|
|
381
|
+
}, ref) => {
|
|
382
|
+
const Comp = asChild ? Slot : View;
|
|
383
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
384
|
+
ref: ref,
|
|
385
|
+
className: cn(insightContentVariants(), className),
|
|
386
|
+
style: style,
|
|
387
|
+
...props,
|
|
388
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
389
|
+
slot: 'insight-content'
|
|
390
|
+
})),
|
|
391
|
+
children: children
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
InsightContent.displayName = 'Insight.Content';
|
|
395
|
+
|
|
396
|
+
// =============================================================================
|
|
397
|
+
// FOOTER
|
|
398
|
+
// =============================================================================
|
|
399
|
+
|
|
400
|
+
const InsightFooter = /*#__PURE__*/forwardRef(({
|
|
401
|
+
asChild,
|
|
402
|
+
className,
|
|
403
|
+
children,
|
|
404
|
+
style,
|
|
405
|
+
...props
|
|
406
|
+
}, ref) => {
|
|
407
|
+
const Comp = asChild ? Slot : View;
|
|
408
|
+
return /*#__PURE__*/_jsx(Comp, {
|
|
409
|
+
ref: ref,
|
|
410
|
+
className: cn(insightFooterVariants(), className),
|
|
411
|
+
style: style,
|
|
412
|
+
...props,
|
|
413
|
+
...mergeDataAttributes(props, dataAttributes({
|
|
414
|
+
slot: 'insight-footer'
|
|
415
|
+
})),
|
|
416
|
+
children: children
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
InsightFooter.displayName = 'Insight.Footer';
|
|
420
|
+
|
|
421
|
+
// =============================================================================
|
|
422
|
+
// COMPOUND COMPONENT
|
|
423
|
+
// =============================================================================
|
|
424
|
+
|
|
425
|
+
export const Insight = Object.assign(InsightRootStyled, {
|
|
426
|
+
Tag: InsightTag,
|
|
427
|
+
Header: InsightHeader,
|
|
428
|
+
Title: InsightTitle,
|
|
429
|
+
Description: InsightDescription,
|
|
430
|
+
Content: InsightContent,
|
|
431
|
+
Footer: InsightFooter
|
|
432
|
+
});
|
|
433
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cloneElement","forwardRef","isValidElement","useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","Platform","Text","View","Animated","useAnimatedStyle","useSharedValue","withTiming","useCSSVariable","InsightRoot","Slot","dataAttributes","mergeDataAttributes","useInsightContext","Close","Sparkle","cn","createContext","ParentContext","useParentContext","useStyleContext","Avatar","Chip","IconButton","useCombinedAnimationDisabledState","insetRadius","FRAME_WIDTH","insightCloseVariants","insightContentVariants","insightDescriptionVariants","insightFooterVariants","insightFrameVariants","insightHeaderVariants","insightIconVariants","insightPressRegionVariants","insightSummaryTextVariants","insightSurfaceVariants","insightTagIconVariants","insightTagVariants","insightTitleVariants","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SCOPE","useInsightStyleContext","InsightTagRegistryProvider","useInsightTagRegistry","hasWarnedMissingTag","PRESSED_SCALE","PRESS_SCALE_DURATION_MS","InsightPressScale","scale","isPressed","isPressable","isAllAnimationsDisabled","undefined","set","duration","SummaryBody","hasClose","children","color","accessibilityElementsHidden","importantForAccessibility","slot","size","variant","Icon","as","className","InsightRootStyled","props","ref","aiGenerated","onClose","closeAccessibilityLabel","asChild","style","rootProps","layout","onPress","isDisabled","asChildElement","isSplit","pressScaleStyle","transform","get","tag","setTag","tagOwnerRef","registerTag","owner","next","current","registry","__DEV__","console","warn","radiusVariable","surfaceRadius","OS","surfaceStyle","borderRadius","parent","ctx","content","closeButton","accessibilityLabel","Provider","value","disabled","InsightTagChip","accessory","split","pressableClassName","displayName","position","Label","InsightTag","InsightHeader","Comp","InsightTitle","role","InsightDescription","InsightContent","InsightFooter","Insight","Object","assign","Tag","Header","Title","Description","Content","Footer"],"sourceRoot":"../../../../src","sources":["components/Insight/index.tsx"],"mappings":";;AAAA,SACEA,YAAY,EACZC,UAAU,EACVC,cAAc,EACdC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAIH,OAAO;AACd,SAASC,QAAQ,EAAEC,IAAI,EAAEC,IAAI,QAAwC,cAAc;AACnF,OAAOC,QAAQ,IACbC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QAEL,yBAAyB;AAChC,SAASC,cAAc,QAAQ,SAAS;AACxC,SACEC,WAAW,EACXC,IAAI,EACJC,cAAc,EACdC,mBAAmB,EACnBC,iBAAiB,QAIZ,oBAAoB;AAC3B,SAASC,KAAK,EAAEC,OAAO,QAAQ,eAAe;AAC9C,SAASC,EAAE,EAAEC,aAAa,EAAEC,aAAa,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,eAAe;AACnG,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,iCAAiC,QAAQ,iBAAiB;AACnE,SAASC,WAAW,QAAQ,eAAe;AAC3C,SACEC,WAAW,EACXC,oBAAoB,EACpBC,sBAAsB,EACtBC,0BAA0B,EAC1BC,qBAAqB,EACrBC,oBAAoB,EACpBC,qBAAqB,EACrBC,mBAAmB,EACnBC,0BAA0B,EAC1BC,0BAA0B,EAC1BC,sBAAsB,EACtBC,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AEzEA;EAAQ,CACL,CAAC;AAEX,CACF,CAAC;AAEDiE,aAAa,CAACV,WAAW,GAAG,gBAAgB;;AAE5C;AACA;AACA;;AAWA,OAAO,MAAMW,OAAO,GAAGC,MAAM,CAACC,MAAM,CAAC1D,iBAAiB,EAAE;EACtD2D,GAAG,EAAEX,UAAU;EACfY,MAAM,EAAEX,aAAa;EACrBY,KAAK,EAAEV,YAAY;EACnBW,WAAW,EAAET,kBAAkB;EAC/BU,OAAO,EAAET,cAAc;EACvBU,MAAM,EAAET;AACV,CAAC,CAA6B","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const ROOT_FONT_SIZE_PX = 16;
|
|
4
|
+
const LENGTH_PATTERN = /^(-?\d*\.?\d+)(px|rem)?$/;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Converts a resolved CSS variable (a number, or a `px`/`rem` string) to pixels. Native resolves
|
|
8
|
+
* built-in tokens to numbers, while runtime theme overrides and the web resolve to strings.
|
|
9
|
+
*/
|
|
10
|
+
export function cssLengthToPx(value) {
|
|
11
|
+
if (typeof value === 'number') {
|
|
12
|
+
return Number.isFinite(value) ? value : undefined;
|
|
13
|
+
}
|
|
14
|
+
if (typeof value !== 'string') {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const match = LENGTH_PATTERN.exec(value.trim());
|
|
18
|
+
if (!match) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const amount = Number(match[1]);
|
|
22
|
+
return match[2] === 'rem' ? amount * ROOT_FONT_SIZE_PX : amount;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The radius of a surface inset `inset` px inside a frame with radius `outer`, or `undefined` when `outer` is not a length. */
|
|
26
|
+
export function insetRadius(outer, inset) {
|
|
27
|
+
const px = cssLengthToPx(outer);
|
|
28
|
+
return px === undefined ? undefined : Math.max(0, px - inset);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=insetRadius.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ROOT_FONT_SIZE_PX","LENGTH_PATTERN","cssLengthToPx","value","Number","isFinite","undefined","match","exec","trim","amount","insetRadius","outer","inset","px","Math","max"],"sourceRoot":"../../../../src","sources":["components/Insight/insetRadius.ts"],"mappings":";;AAAA,MAAMA,iBAAiB,GAAG,EAAE;AAE5B,MAAMC,cAAc,GAAG,0BAA0B;;AAEjD;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,KAAkC,EAAsB;EACpF,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAOC,MAAM,CAACC,QAAQ,CAACF,KAAK,CAAC,GAAGA,KAAK,GAAGG,SAAS;EACnD;EACA,IAAI,OAAOH,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAOG,SAAS;EAClB;EAEA,MAAMC,KAAK,GAAGN,cAAc,CAACO,IAAI,CAACL,KAAK,CAACM,IAAI,CAAC,CAAC,CAAC;EAC/C,IAAI,CAACF,KAAK,EAAE;IACV,OAAOD,SAAS;EAClB;EAEA,MAAMI,MAAM,GAAGN,MAAM,CAACG,KAAK,CAAC,CAAC,CAAC,CAAC;EAC/B,OAAOA,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,GAAGG,MAAM,GAAGV,iBAAiB,GAAGU,MAAM;AACjE;;AAEA;AACA,OAAO,SAASC,WAAWA,CAACC,KAAkC,EAAEC,KAAa,EAAsB;EACjG,MAAMC,EAAE,GAAGZ,aAAa,CAACU,KAAK,CAAC;EAC/B,OAAOE,EAAE,KAAKR,SAAS,GAAGA,SAAS,GAAGS,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEF,EAAE,GAAGD,KAAK,CAAC;AAC/D","ignoreList":[]}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { cva } from '@cdx-ui/utils';
|
|
4
|
+
import { DISABLED_CURSOR } from '../../styles/constants';
|
|
5
|
+
|
|
6
|
+
/** Ring width in px; must match the frame's `p-0.5`. */
|
|
7
|
+
export const FRAME_WIDTH = 2;
|
|
8
|
+
|
|
9
|
+
// Fallback for when `--border-radius-default` can't be read; the surface style overrides it.
|
|
10
|
+
const SURFACE_RADIUS = 'rounded-[calc(var(--border-radius-default)-2px)]';
|
|
11
|
+
|
|
12
|
+
// Figma measures padding from inside the 2px stroke, and the frame's `p-0.5` is that stroke, so
|
|
13
|
+
// these are the Figma values as-is. `min-h-14` is the natural one-line height: 12 + 32 + 12.
|
|
14
|
+
const SUMMARY_BODY = 'flex-row items-start gap-2.5 min-h-14 pt-2.5 pb-3 ps-2.5 pe-3';
|
|
15
|
+
|
|
16
|
+
// The standard web focus ring (2px `stroke-focus`, 2px clear of the card's edge) and disabled
|
|
17
|
+
// cursor, on whichever element takes focus. That element sits inside the 2px frame, and a
|
|
18
|
+
// `ring-offset` would paint its offset colour over the frame, so the ring is an outline: its
|
|
19
|
+
// offset stays transparent and it follows the surface radius. Figma has no hover or press tint
|
|
20
|
+
// for the card; the press scale is its only press feedback.
|
|
21
|
+
const PRESS_REGION_STATE = ['web:outline-none', DISABLED_CURSOR, 'web:data-[focus-visible=true]:outline-2 web:data-[focus-visible=true]:outline-solid web:data-[focus-visible=true]:outline-stroke-focus web:data-[focus-visible=true]:outline-offset-4'].join(' ');
|
|
22
|
+
|
|
23
|
+
// ── Frame ───────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
// The frame dims as a whole when disabled: dimming only the surface would let the frame's fill
|
|
26
|
+
// show through it.
|
|
27
|
+
export const insightFrameVariants = cva(['relative p-0.5', 'rounded-[var(--border-radius-default)]', 'data-[disabled=true]:opacity-[var(--opacity-disabled)]'], {
|
|
28
|
+
variants: {
|
|
29
|
+
layout: {
|
|
30
|
+
summary: '',
|
|
31
|
+
// Reserves the tag overhang (11px above the outer edge) so a scroll container's top
|
|
32
|
+
// edge does not clip it.
|
|
33
|
+
detail: 'mt-[11px]'
|
|
34
|
+
},
|
|
35
|
+
color: {
|
|
36
|
+
info: '',
|
|
37
|
+
warning: '',
|
|
38
|
+
danger: ''
|
|
39
|
+
},
|
|
40
|
+
aiGenerated: {
|
|
41
|
+
true: 'bg-gradient-to-r from-stroke-ai-start to-stroke-ai-end',
|
|
42
|
+
false: ''
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
compoundVariants: [{
|
|
46
|
+
aiGenerated: false,
|
|
47
|
+
color: 'info',
|
|
48
|
+
className: 'bg-stroke-info-subtle'
|
|
49
|
+
}, {
|
|
50
|
+
aiGenerated: false,
|
|
51
|
+
color: 'warning',
|
|
52
|
+
className: 'bg-stroke-warning-subtle'
|
|
53
|
+
}, {
|
|
54
|
+
aiGenerated: false,
|
|
55
|
+
color: 'danger',
|
|
56
|
+
className: 'bg-stroke-danger-subtle'
|
|
57
|
+
},
|
|
58
|
+
// The AI glow takes the insight's colour; the gradient ring does not.
|
|
59
|
+
{
|
|
60
|
+
aiGenerated: true,
|
|
61
|
+
color: 'info',
|
|
62
|
+
className: 'shadow-[0_0_3px_var(--color-surface-info-subtle)]'
|
|
63
|
+
}, {
|
|
64
|
+
aiGenerated: true,
|
|
65
|
+
color: 'warning',
|
|
66
|
+
className: 'shadow-[0_0_3px_var(--color-surface-warning-subtle)]'
|
|
67
|
+
}, {
|
|
68
|
+
aiGenerated: true,
|
|
69
|
+
color: 'danger',
|
|
70
|
+
className: 'shadow-[0_0_3px_var(--color-surface-danger-subtle)]'
|
|
71
|
+
}],
|
|
72
|
+
defaultVariants: {
|
|
73
|
+
layout: 'summary',
|
|
74
|
+
color: 'info',
|
|
75
|
+
aiGenerated: false
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// ── Surface ─────────────────────────────────────────────────
|
|
80
|
+
|
|
81
|
+
export const insightSurfaceVariants = cva(['bg-surface-primary', SURFACE_RADIUS], {
|
|
82
|
+
variants: {
|
|
83
|
+
layout: {
|
|
84
|
+
summary: '',
|
|
85
|
+
detail: 'pt-5 px-3 pb-3 gap-4'
|
|
86
|
+
},
|
|
87
|
+
// A split summary moves the body layout onto the press region.
|
|
88
|
+
split: {
|
|
89
|
+
true: '',
|
|
90
|
+
false: ''
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
// A split summary's surface only mirrors the press region's state, so the region styles it.
|
|
94
|
+
compoundVariants: [{
|
|
95
|
+
layout: 'summary',
|
|
96
|
+
split: false,
|
|
97
|
+
className: [SUMMARY_BODY, PRESS_REGION_STATE]
|
|
98
|
+
}],
|
|
99
|
+
defaultVariants: {
|
|
100
|
+
layout: 'summary',
|
|
101
|
+
split: false
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Web-only radius: the region has no fill, so the radius only shapes the web focus outline, and
|
|
106
|
+
// on native a runtime `px` override turns the `calc()` into NaN.
|
|
107
|
+
export const insightPressRegionVariants = cva([SUMMARY_BODY, 'web:rounded-[calc(var(--border-radius-default)-2px)]', PRESS_REGION_STATE]);
|
|
108
|
+
|
|
109
|
+
// ── Summary medallion icon ──────────────────────────────────
|
|
110
|
+
|
|
111
|
+
// `size-5` overrides Avatar md's `size-4`: the Figma medallion glyph is 20px.
|
|
112
|
+
export const insightIconVariants = cva(['size-5'], {
|
|
113
|
+
variants: {
|
|
114
|
+
color: {
|
|
115
|
+
info: 'text-content-info-on-subtle',
|
|
116
|
+
warning: 'text-content-warning-on-subtle',
|
|
117
|
+
danger: 'text-content-danger-on-subtle'
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
defaultVariants: {
|
|
121
|
+
color: 'info'
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// ── Summary text column ─────────────────────────────────────
|
|
126
|
+
|
|
127
|
+
// Figma's text row is a 32px-min band, centred, starting 2px below the medallion's top. One line
|
|
128
|
+
// sits centred against the medallion; longer copy grows downward while the medallion stays put.
|
|
129
|
+
export const insightSummaryTextVariants = cva(['flex-1 min-w-0 mt-0.5 min-h-8 justify-center'], {
|
|
130
|
+
variants: {
|
|
131
|
+
hasClose: {
|
|
132
|
+
true: 'pe-7',
|
|
133
|
+
false: ''
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
defaultVariants: {
|
|
137
|
+
hasClose: false
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// ── Tag ─────────────────────────────────────────────────────
|
|
142
|
+
|
|
143
|
+
// Positioned against the frame's outer edge: the 24px chip centres on the 2px stroke (-11px) and
|
|
144
|
+
// starts 12px from the outer start edge.
|
|
145
|
+
export const insightTagVariants = cva(['absolute z-10 -top-[11px] start-3']);
|
|
146
|
+
export const insightTagIconVariants = cva([], {
|
|
147
|
+
variants: {
|
|
148
|
+
color: {
|
|
149
|
+
info: 'text-content-info-on-subtle',
|
|
150
|
+
warning: 'text-content-warning-on-subtle',
|
|
151
|
+
danger: 'text-content-danger-on-subtle'
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
defaultVariants: {
|
|
155
|
+
color: 'info'
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// ── Close ───────────────────────────────────────────────────
|
|
160
|
+
|
|
161
|
+
// Positioned against the surface (inside the ring): 4px from its top and end, as in Figma.
|
|
162
|
+
export const insightCloseVariants = cva(['absolute top-1 end-1']);
|
|
163
|
+
|
|
164
|
+
// ── Header / Title / Description / Content / Footer ─────────
|
|
165
|
+
|
|
166
|
+
export const insightHeaderVariants = cva(['gap-0.5 min-h-8 justify-center']);
|
|
167
|
+
export const insightTitleVariants = cva(['heading-sm text-content-primary'], {
|
|
168
|
+
variants: {
|
|
169
|
+
hasClose: {
|
|
170
|
+
true: 'pe-7',
|
|
171
|
+
false: ''
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
defaultVariants: {
|
|
175
|
+
hasClose: false
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
export const insightDescriptionVariants = cva(['body-md text-content-primary']);
|
|
179
|
+
export const insightContentVariants = cva([]);
|
|
180
|
+
|
|
181
|
+
// Wraps so actions keep their natural widths at narrow widths instead of overflowing the start edge.
|
|
182
|
+
export const insightFooterVariants = cva(['flex-row flex-wrap items-center justify-end gap-2']);
|
|
183
|
+
//# sourceMappingURL=styles.js.map
|