@cdx-ui/components 0.3.2 → 0.3.3
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/content.md +2 -0
- package/docs/components/data-grid/content.md +125 -1
- package/docs/components/insight/content.md +644 -0
- package/docs/components/insight-stack/content.md +231 -0
- package/docs/foundations/styles/tokens/all-tokens/content.md +23 -3
- package/docs/llms.txt +3 -0
- package/docs/patterns/forms/content.md +255 -0
- package/docs/resources/release-notes/0.3.2/content.md +17 -0
- package/docs/resources/release-notes/content.md +1 -0
- 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/index.js +24 -0
- package/lib/commonjs/components/index.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/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/index.js +2 -0
- package/lib/module/components/index.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/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/index.d.ts +2 -0
- package/lib/typescript/components/index.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/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/index.ts +2 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _figma = _interopRequireDefault(require("figma"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
// url=https://www.figma.com/design/0lEVMVlLj8ZS4fgItr3pmd/%E2%AD%90-Forge-DS--Components?node-id=13652-32306
|
|
10
|
+
// source=packages/components/src/components/InsightStack/index.tsx
|
|
11
|
+
// component=InsightStack
|
|
12
|
+
|
|
13
|
+
const instance = _figma.default.selectedInstance;
|
|
14
|
+
|
|
15
|
+
// Figma's `3+` bucket becomes the smallest count that draws both layers; code takes a number.
|
|
16
|
+
const count = instance.getEnum('count', {
|
|
17
|
+
'1': 1,
|
|
18
|
+
'2': 2,
|
|
19
|
+
'3+': 3
|
|
20
|
+
});
|
|
21
|
+
const countProp = _figma.default.helpers.react.renderProp('count', count);
|
|
22
|
+
|
|
23
|
+
// Found by Code Connect id, so the front card's layer name does not matter.
|
|
24
|
+
const frontInsight = instance.findConnectedInstance('insight', {
|
|
25
|
+
traverseInstances: true
|
|
26
|
+
});
|
|
27
|
+
const frontSnippet = frontInsight?.type === 'INSTANCE' ? frontInsight.executeTemplate().example : _figma.default.code`<Insight layout="summary">
|
|
28
|
+
<Insight.Description>Description</Insight.Description>
|
|
29
|
+
</Insight>`;
|
|
30
|
+
var _default = exports.default = {
|
|
31
|
+
id: 'insight-stack',
|
|
32
|
+
// Separate strings so the nested Insight template's identical import is deduped.
|
|
33
|
+
imports: ["import { InsightStack } from '@cdx-ui/components'", "import { Insight } from '@cdx-ui/components'"],
|
|
34
|
+
example: _figma.default.code`
|
|
35
|
+
<InsightStack${countProp}>
|
|
36
|
+
${frontSnippet}
|
|
37
|
+
</InsightStack>`
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=InsightStack.figma.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_figma","_interopRequireDefault","require","e","__esModule","default","instance","figma","selectedInstance","count","getEnum","countProp","helpers","react","renderProp","frontInsight","findConnectedInstance","traverseInstances","frontSnippet","type","executeTemplate","example","code","_default","exports","id","imports"],"sourceRoot":"../../../src","sources":["figma/InsightStack.figma.ts"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAH1B;AACA;AACA;;AAGA,MAAMG,QAAQ,GAAGC,cAAK,CAACC,gBAAgB;;AAEvC;AACA,MAAMC,KAAK,GAAGH,QAAQ,CAACI,OAAO,CAAC,OAAO,EAAE;EACtC,GAAG,EAAE,CAAC;EACN,GAAG,EAAE,CAAC;EACN,IAAI,EAAE;AACR,CAAC,CAAC;AACF,MAAMC,SAAS,GAAGJ,cAAK,CAACK,OAAO,CAACC,KAAK,CAACC,UAAU,CAAC,OAAO,EAAEL,KAAK,CAAC;;AAEhE;AACA,MAAMM,YAAY,GAAGT,QAAQ,CAACU,qBAAqB,CAAC,SAAS,EAAE;EAAEC,iBAAiB,EAAE;AAAK,CAAC,CAAC;AAC3F,MAAMC,YAAY,GAChBH,YAAY,EAAEI,IAAI,KAAK,UAAU,GAC7BJ,YAAY,CAACK,eAAe,CAAC,CAAC,CAACC,OAAO,GACtCd,cAAK,CAACe,IAAI;AAChB;AACA,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAnB,OAAA,GAEC;EACboB,EAAE,EAAE,eAAe;EACnB;EACAC,OAAO,EAAE,CACP,mDAAmD,EACnD,8CAA8C,CAC/C;EACDL,OAAO,EAAEd,cAAK,CAACe,IAAI;AACrB,eAAeX,SAAS;AACxB,IAAIO,YAAY;AAChB;AACA,CAAC","ignoreList":[]}
|
|
@@ -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,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AC,CAAC,CAAC;IAAAJ,QAAA,EAE1EA;EAAQ,CACL,CAAC;AAEX,CACF,CAAC;AAEDgE,cAAc,CAACT,WAAW,GAAG,iBAAiB;;AAE9C;AACA;AACA;;AAQA,MAAMU,aAAa,gBAAGvI,UAAU,CAC9B,CAAC;EAAEsF,OAAO;EAAEP,SAAS;EAAET,QAAQ;EAAEiB,KAAK;EAAE,GAAGN;AAAM,CAAC,EAAEC,GAAG,KAAK;EAC1D,MAAMgD,IAAI,GAAG5C,OAAO,GAAGrE,IAAI,GAAGP,IAAI;EAElC,oBACEsC,IAAA,CAACkF,IAAI;IACHhD,GAAG,EAAEA,GAAI;IACTH,SAAS,EAAExD,EAAE,CAACc,qBAAqB,CAAC,CAAC,EAAE0C,SAAS,CAAE;IAClDQ,KAAK,EAAEA,KAAM;IAAA,GACTN,KAAK;IAAA,GACL9D,mBAAmB,CAAC8D,KAAK,EAAE/D,cAAc,CAAC;MAAEwD,IAAI,EAAE;IAAiB,CAAC,CAAC,CAAC;IAAAJ,QAAA,EAEzEA;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":[]}
|