@dangerousthings/react-native 0.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/dist/components/DTAccordion.d.ts +75 -0
- package/dist/components/DTAccordion.d.ts.map +1 -0
- package/dist/components/DTAccordion.js +147 -0
- package/dist/components/DTAccordion.js.map +1 -0
- package/dist/components/DTButton.d.ts +68 -0
- package/dist/components/DTButton.d.ts.map +1 -0
- package/dist/components/DTButton.js +59 -0
- package/dist/components/DTButton.js.map +1 -0
- package/dist/components/DTCard.d.ts +97 -0
- package/dist/components/DTCard.d.ts.map +1 -0
- package/dist/components/DTCard.js +81 -0
- package/dist/components/DTCard.js.map +1 -0
- package/dist/components/DTCheckbox.d.ts +63 -0
- package/dist/components/DTCheckbox.d.ts.map +1 -0
- package/dist/components/DTCheckbox.js +55 -0
- package/dist/components/DTCheckbox.js.map +1 -0
- package/dist/components/DTChip.d.ts +40 -0
- package/dist/components/DTChip.d.ts.map +1 -0
- package/dist/components/DTChip.js +55 -0
- package/dist/components/DTChip.js.map +1 -0
- package/dist/components/DTDrawer.d.ts +82 -0
- package/dist/components/DTDrawer.d.ts.map +1 -0
- package/dist/components/DTDrawer.js +146 -0
- package/dist/components/DTDrawer.js.map +1 -0
- package/dist/components/DTGallery.d.ts +83 -0
- package/dist/components/DTGallery.d.ts.map +1 -0
- package/dist/components/DTGallery.js +160 -0
- package/dist/components/DTGallery.js.map +1 -0
- package/dist/components/DTHexagon.d.ts +81 -0
- package/dist/components/DTHexagon.d.ts.map +1 -0
- package/dist/components/DTHexagon.js +110 -0
- package/dist/components/DTHexagon.js.map +1 -0
- package/dist/components/DTLabel.d.ts +100 -0
- package/dist/components/DTLabel.d.ts.map +1 -0
- package/dist/components/DTLabel.js +189 -0
- package/dist/components/DTLabel.js.map +1 -0
- package/dist/components/DTMediaFrame.d.ts +77 -0
- package/dist/components/DTMediaFrame.d.ts.map +1 -0
- package/dist/components/DTMediaFrame.js +84 -0
- package/dist/components/DTMediaFrame.js.map +1 -0
- package/dist/components/DTMenu.d.ts +119 -0
- package/dist/components/DTMenu.d.ts.map +1 -0
- package/dist/components/DTMenu.js +188 -0
- package/dist/components/DTMenu.js.map +1 -0
- package/dist/components/DTModal.d.ts +64 -0
- package/dist/components/DTModal.d.ts.map +1 -0
- package/dist/components/DTModal.js +45 -0
- package/dist/components/DTModal.js.map +1 -0
- package/dist/components/DTProgressBar.d.ts +66 -0
- package/dist/components/DTProgressBar.d.ts.map +1 -0
- package/dist/components/DTProgressBar.js +82 -0
- package/dist/components/DTProgressBar.js.map +1 -0
- package/dist/components/DTQuantityStepper.d.ts +76 -0
- package/dist/components/DTQuantityStepper.d.ts.map +1 -0
- package/dist/components/DTQuantityStepper.js +108 -0
- package/dist/components/DTQuantityStepper.js.map +1 -0
- package/dist/components/DTRadioGroup.d.ts +79 -0
- package/dist/components/DTRadioGroup.d.ts.map +1 -0
- package/dist/components/DTRadioGroup.js +107 -0
- package/dist/components/DTRadioGroup.js.map +1 -0
- package/dist/components/DTSearchInput.d.ts +72 -0
- package/dist/components/DTSearchInput.d.ts.map +1 -0
- package/dist/components/DTSearchInput.js +71 -0
- package/dist/components/DTSearchInput.js.map +1 -0
- package/dist/components/DTSwitch.d.ts +52 -0
- package/dist/components/DTSwitch.d.ts.map +1 -0
- package/dist/components/DTSwitch.js +85 -0
- package/dist/components/DTSwitch.js.map +1 -0
- package/dist/components/DTTextInput.d.ts +58 -0
- package/dist/components/DTTextInput.d.ts.map +1 -0
- package/dist/components/DTTextInput.js +85 -0
- package/dist/components/DTTextInput.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/theme/DTThemeProvider.d.ts +49 -0
- package/dist/theme/DTThemeProvider.d.ts.map +1 -0
- package/dist/theme/DTThemeProvider.js +52 -0
- package/dist/theme/DTThemeProvider.js.map +1 -0
- package/dist/theme/colors.d.ts +42 -0
- package/dist/theme/colors.d.ts.map +1 -0
- package/dist/theme/colors.js +59 -0
- package/dist/theme/colors.js.map +1 -0
- package/dist/theme/paperTheme.d.ts +39 -0
- package/dist/theme/paperTheme.d.ts.map +1 -0
- package/dist/theme/paperTheme.js +116 -0
- package/dist/theme/paperTheme.js.map +1 -0
- package/dist/theme/typography.d.ts +57 -0
- package/dist/theme/typography.d.ts.map +1 -0
- package/dist/theme/typography.js +170 -0
- package/dist/theme/typography.js.map +1 -0
- package/dist/utils/bevelPaths.d.ts +42 -0
- package/dist/utils/bevelPaths.d.ts.map +1 -0
- package/dist/utils/bevelPaths.js +105 -0
- package/dist/utils/bevelPaths.js.map +1 -0
- package/dist/utils/useComponentLayout.d.ts +18 -0
- package/dist/utils/useComponentLayout.d.ts.map +1 -0
- package/dist/utils/useComponentLayout.js +24 -0
- package/dist/utils/useComponentLayout.js.map +1 -0
- package/dist/utils/variantColors.d.ts +12 -0
- package/dist/utils/variantColors.d.ts.map +1 -0
- package/dist/utils/variantColors.js +20 -0
- package/dist/utils/variantColors.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* DT MediaFrame Component
|
|
4
|
+
*
|
|
5
|
+
* A beveled frame for images and video content following the
|
|
6
|
+
* Dangerous Things design language. No RNP equivalent.
|
|
7
|
+
*
|
|
8
|
+
* Web CSS reference (CyberMediaFrame / .media-frame-clipped):
|
|
9
|
+
* - Top-left + bottom-right diagonal symmetry bevels
|
|
10
|
+
* - Colored border with dark inner background
|
|
11
|
+
* - Optional mount scale animation
|
|
12
|
+
*/
|
|
13
|
+
import { useRef, useEffect } from 'react';
|
|
14
|
+
import { StyleSheet, View, Animated } from 'react-native';
|
|
15
|
+
import Svg, { Path, Defs, ClipPath } from 'react-native-svg';
|
|
16
|
+
import { DTColors } from '../theme/colors';
|
|
17
|
+
import { getVariantColor } from '../utils/variantColors';
|
|
18
|
+
import { buildMediaFrameBevelPath } from '../utils/bevelPaths';
|
|
19
|
+
import { useComponentLayout } from '../utils/useComponentLayout';
|
|
20
|
+
/**
|
|
21
|
+
* DT-styled MediaFrame with diagonal-symmetry beveled corners
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* <DTMediaFrame variant="normal" aspectRatio={16/9}>
|
|
25
|
+
* <Image source={{uri: imageUrl}} style={{flex: 1}} />
|
|
26
|
+
* </DTMediaFrame>
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* <DTMediaFrame variant="emphasis" bevelSize={24}>
|
|
30
|
+
* <Video source={videoSource} />
|
|
31
|
+
* </DTMediaFrame>
|
|
32
|
+
*/
|
|
33
|
+
export function DTMediaFrame({ children, variant = 'normal', aspectRatio, borderWidth = 3, bevelSize = 32, animated = true, animationDelay = 0, color, style, contentStyle, }) {
|
|
34
|
+
const { dimensions, onLayout, hasDimensions } = useComponentLayout();
|
|
35
|
+
const scaleAnim = useRef(new Animated.Value(animated ? 0 : 1)).current;
|
|
36
|
+
const accentColor = getVariantColor(variant, color);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (animated) {
|
|
39
|
+
Animated.timing(scaleAnim, {
|
|
40
|
+
toValue: 1,
|
|
41
|
+
duration: 300,
|
|
42
|
+
delay: animationDelay,
|
|
43
|
+
useNativeDriver: true,
|
|
44
|
+
}).start();
|
|
45
|
+
}
|
|
46
|
+
}, [animated, animationDelay, scaleAnim]);
|
|
47
|
+
const { width, height } = dimensions;
|
|
48
|
+
// Outer bevel path (full frame shape)
|
|
49
|
+
const outerPath = hasDimensions
|
|
50
|
+
? buildMediaFrameBevelPath(width, height, bevelSize)
|
|
51
|
+
: '';
|
|
52
|
+
// Inner bevel path at border inset
|
|
53
|
+
const innerPath = hasDimensions
|
|
54
|
+
? buildMediaFrameBevelPath(width, height, bevelSize - borderWidth, borderWidth)
|
|
55
|
+
: '';
|
|
56
|
+
return (_jsxs(Animated.View, { style: [
|
|
57
|
+
styles.container,
|
|
58
|
+
aspectRatio ? { aspectRatio } : undefined,
|
|
59
|
+
{ transform: [{ scale: scaleAnim }] },
|
|
60
|
+
style,
|
|
61
|
+
], onLayout: onLayout, children: [hasDimensions && (_jsx(Svg, { style: StyleSheet.absoluteFill, width: width, height: height, viewBox: `0 0 ${width} ${height}`, children: _jsx(Path, { d: innerPath, fill: DTColors.dark }) })), hasDimensions ? (_jsxs(View, { style: [styles.content, contentStyle], children: [_jsx(Svg, { width: width, height: height, viewBox: `0 0 ${width} ${height}`, style: StyleSheet.absoluteFill, children: _jsx(Defs, { children: _jsx(ClipPath, { id: "mediaClip", children: _jsx(Path, { d: innerPath }) }) }) }), _jsx(View, { style: [
|
|
62
|
+
StyleSheet.absoluteFill,
|
|
63
|
+
{
|
|
64
|
+
margin: borderWidth,
|
|
65
|
+
// Use borderRadius 0 to keep angular, overflow hidden clips rectangular part
|
|
66
|
+
overflow: 'hidden',
|
|
67
|
+
},
|
|
68
|
+
], children: children })] })) : (_jsx(View, { style: [styles.content, { padding: borderWidth }, contentStyle], children: children })), hasDimensions && (_jsxs(Svg, { style: [StyleSheet.absoluteFill, styles.frameOverlay], width: width, height: height, viewBox: `0 0 ${width} ${height}`, pointerEvents: "none", children: [_jsx(Path, { d: outerPath + ' ' + innerPath, fillRule: "evenodd", fill: accentColor }), _jsx(Path, { d: `M 0 0 L ${width} 0 L ${width} ${height} L 0 ${height} Z ` + outerPath, fillRule: "evenodd", fill: DTColors.dark })] }))] }));
|
|
69
|
+
}
|
|
70
|
+
const styles = StyleSheet.create({
|
|
71
|
+
container: {
|
|
72
|
+
position: 'relative',
|
|
73
|
+
},
|
|
74
|
+
content: {
|
|
75
|
+
position: 'relative',
|
|
76
|
+
zIndex: 1,
|
|
77
|
+
overflow: 'hidden',
|
|
78
|
+
flex: 1,
|
|
79
|
+
},
|
|
80
|
+
frameOverlay: {
|
|
81
|
+
zIndex: 2,
|
|
82
|
+
},
|
|
83
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AAM,CAAC;IAC/B,SAAS,EAAE;QACT,QAAQ,EAAE,UAAU;KACrB;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,CAAC;QACT,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,CAAC;KACR;IACD,YAAY,EAAE;QACZ,MAAM,EAAE,CAAC;KACV;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DT Menu Component
|
|
3
|
+
*
|
|
4
|
+
* Wraps React Native Paper's Menu for dropdown positioning, with custom
|
|
5
|
+
* menu items styled to the Dangerous Things aesthetic.
|
|
6
|
+
*
|
|
7
|
+
* Web CSS reference (CyberMenu):
|
|
8
|
+
* - Hierarchical items with menu-item-clipped styling
|
|
9
|
+
* - Active/selected state with emphasis color fill
|
|
10
|
+
* - borderTopWidth: 5 thick accent border
|
|
11
|
+
*/
|
|
12
|
+
import { ViewStyle, StyleProp } from 'react-native';
|
|
13
|
+
import { type DTVariant } from '../utils/variantColors';
|
|
14
|
+
export interface DTMenuItem {
|
|
15
|
+
/**
|
|
16
|
+
* Unique identifier
|
|
17
|
+
*/
|
|
18
|
+
id: string;
|
|
19
|
+
/**
|
|
20
|
+
* Display title
|
|
21
|
+
*/
|
|
22
|
+
title: string;
|
|
23
|
+
/**
|
|
24
|
+
* Press handler (leaf items)
|
|
25
|
+
*/
|
|
26
|
+
onPress?: () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Sub-menu items
|
|
29
|
+
*/
|
|
30
|
+
items?: DTMenuItem[];
|
|
31
|
+
/**
|
|
32
|
+
* Whether this item is currently active
|
|
33
|
+
*/
|
|
34
|
+
isActive?: boolean;
|
|
35
|
+
}
|
|
36
|
+
interface DTMenuProps {
|
|
37
|
+
/**
|
|
38
|
+
* Menu items
|
|
39
|
+
*/
|
|
40
|
+
items: DTMenuItem[];
|
|
41
|
+
/**
|
|
42
|
+
* Visual variant
|
|
43
|
+
* @default 'normal'
|
|
44
|
+
*/
|
|
45
|
+
variant?: DTVariant;
|
|
46
|
+
/**
|
|
47
|
+
* Variant for active items
|
|
48
|
+
* @default 'emphasis'
|
|
49
|
+
*/
|
|
50
|
+
activeVariant?: DTVariant;
|
|
51
|
+
/**
|
|
52
|
+
* Layout direction
|
|
53
|
+
* @default 'vertical'
|
|
54
|
+
*/
|
|
55
|
+
layout?: 'horizontal' | 'vertical';
|
|
56
|
+
/**
|
|
57
|
+
* Additional styles
|
|
58
|
+
*/
|
|
59
|
+
style?: StyleProp<ViewStyle>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* DT-styled Menu with hierarchical items
|
|
63
|
+
*
|
|
64
|
+
* For inline menu display (not dropdown). Items with sub-items
|
|
65
|
+
* expand/collapse on press.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* <DTMenu items={[
|
|
69
|
+
* { id: '1', title: 'Home', onPress: goHome, isActive: true },
|
|
70
|
+
* { id: '2', title: 'Products', items: [
|
|
71
|
+
* { id: '2a', title: 'NFC Tags', onPress: goTags },
|
|
72
|
+
* ]},
|
|
73
|
+
* ]} />
|
|
74
|
+
*/
|
|
75
|
+
export declare function DTMenu({ items, variant, activeVariant, layout, style, }: DTMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
76
|
+
/**
|
|
77
|
+
* For dropdown use, wraps RNP Menu for positioning/portal behavior
|
|
78
|
+
*/
|
|
79
|
+
interface DTMenuDropdownProps {
|
|
80
|
+
/**
|
|
81
|
+
* Menu items
|
|
82
|
+
*/
|
|
83
|
+
items: DTMenuItem[];
|
|
84
|
+
/**
|
|
85
|
+
* Visual variant
|
|
86
|
+
* @default 'normal'
|
|
87
|
+
*/
|
|
88
|
+
variant?: DTVariant;
|
|
89
|
+
/**
|
|
90
|
+
* Anchor element or position
|
|
91
|
+
*/
|
|
92
|
+
anchor: React.ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the menu is visible
|
|
95
|
+
*/
|
|
96
|
+
visible: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Called when the menu is dismissed
|
|
99
|
+
*/
|
|
100
|
+
onDismiss: () => void;
|
|
101
|
+
/**
|
|
102
|
+
* Additional styles
|
|
103
|
+
*/
|
|
104
|
+
style?: StyleProp<ViewStyle>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* DT-styled dropdown Menu wrapping React Native Paper Menu
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* <DTMenuDropdown
|
|
111
|
+
* items={menuItems}
|
|
112
|
+
* anchor={<DTButton onPress={open}>Open Menu</DTButton>}
|
|
113
|
+
* visible={menuVisible}
|
|
114
|
+
* onDismiss={() => setMenuVisible(false)}
|
|
115
|
+
* />
|
|
116
|
+
*/
|
|
117
|
+
export declare function DTMenuDropdown({ items, variant, anchor, visible, onDismiss, style, }: DTMenuDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
118
|
+
export {};
|
|
119
|
+
//# sourceMappingURL=DTMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTMenu.d.ts","sourceRoot":"","sources":["../../src/components/DTMenu.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAGL,SAAS,EACT,SAAS,EAGV,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAC,KAAK,SAAS,EAAkB,MAAM,wBAAwB,CAAC;AAEvE,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,UAAU,WAAW;IACnB;;OAEG;IACH,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACnC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,OAAkB,EAClB,aAA0B,EAC1B,MAAmB,EACnB,KAAK,GACN,EAAE,WAAW,2CAmBb;AAED;;GAEG;AACH,UAAU,mBAAmB;IAC3B;;OAEG;IACH,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,OAAkB,EAClB,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,GACN,EAAE,mBAAmB,2CAiCrB"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* DT Menu Component
|
|
4
|
+
*
|
|
5
|
+
* Wraps React Native Paper's Menu for dropdown positioning, with custom
|
|
6
|
+
* menu items styled to the Dangerous Things aesthetic.
|
|
7
|
+
*
|
|
8
|
+
* Web CSS reference (CyberMenu):
|
|
9
|
+
* - Hierarchical items with menu-item-clipped styling
|
|
10
|
+
* - Active/selected state with emphasis color fill
|
|
11
|
+
* - borderTopWidth: 5 thick accent border
|
|
12
|
+
*/
|
|
13
|
+
import { useState, useCallback, useRef, useEffect } from 'react';
|
|
14
|
+
import { StyleSheet, View, Pressable, Animated, } from 'react-native';
|
|
15
|
+
import { Menu, Text } from 'react-native-paper';
|
|
16
|
+
import { DTColors } from '../theme/colors';
|
|
17
|
+
import { getVariantColor } from '../utils/variantColors';
|
|
18
|
+
/**
|
|
19
|
+
* DT-styled Menu with hierarchical items
|
|
20
|
+
*
|
|
21
|
+
* For inline menu display (not dropdown). Items with sub-items
|
|
22
|
+
* expand/collapse on press.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* <DTMenu items={[
|
|
26
|
+
* { id: '1', title: 'Home', onPress: goHome, isActive: true },
|
|
27
|
+
* { id: '2', title: 'Products', items: [
|
|
28
|
+
* { id: '2a', title: 'NFC Tags', onPress: goTags },
|
|
29
|
+
* ]},
|
|
30
|
+
* ]} />
|
|
31
|
+
*/
|
|
32
|
+
export function DTMenu({ items, variant = 'normal', activeVariant = 'emphasis', layout = 'vertical', style, }) {
|
|
33
|
+
return (_jsx(View, { style: [
|
|
34
|
+
styles.container,
|
|
35
|
+
layout === 'horizontal' ? styles.horizontal : styles.vertical,
|
|
36
|
+
style,
|
|
37
|
+
], children: items.map(item => (_jsx(DTMenuItemRow, { item: item, variant: variant, activeVariant: activeVariant, level: 0 }, item.id))) }));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* DT-styled dropdown Menu wrapping React Native Paper Menu
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* <DTMenuDropdown
|
|
44
|
+
* items={menuItems}
|
|
45
|
+
* anchor={<DTButton onPress={open}>Open Menu</DTButton>}
|
|
46
|
+
* visible={menuVisible}
|
|
47
|
+
* onDismiss={() => setMenuVisible(false)}
|
|
48
|
+
* />
|
|
49
|
+
*/
|
|
50
|
+
export function DTMenuDropdown({ items, variant = 'normal', anchor, visible, onDismiss, style, }) {
|
|
51
|
+
const accentColor = getVariantColor(variant);
|
|
52
|
+
return (_jsx(Menu, { visible: visible, onDismiss: onDismiss, anchor: anchor, anchorPosition: "bottom", contentStyle: [
|
|
53
|
+
styles.dropdownContent,
|
|
54
|
+
{ borderColor: accentColor },
|
|
55
|
+
style,
|
|
56
|
+
], theme: {
|
|
57
|
+
colors: {
|
|
58
|
+
elevation: { level2: DTColors.dark },
|
|
59
|
+
},
|
|
60
|
+
}, children: items.map(item => (_jsx(Menu.Item, { title: item.title, onPress: () => {
|
|
61
|
+
item.onPress?.();
|
|
62
|
+
onDismiss();
|
|
63
|
+
}, titleStyle: [styles.dropdownItemTitle, { color: DTColors.light }], style: styles.dropdownItem }, item.id))) }));
|
|
64
|
+
}
|
|
65
|
+
// --- Internal DTMenuItemRow ---
|
|
66
|
+
function DTMenuItemRow({ item, variant, activeVariant, level, }) {
|
|
67
|
+
const [expanded, setExpanded] = useState(false);
|
|
68
|
+
const hasChildren = item.items && item.items.length > 0;
|
|
69
|
+
const isActive = item.isActive || expanded;
|
|
70
|
+
const itemColor = getVariantColor(isActive ? activeVariant : variant);
|
|
71
|
+
const heightAnim = useRef(new Animated.Value(0)).current;
|
|
72
|
+
const chevronAnim = useRef(new Animated.Value(0)).current;
|
|
73
|
+
const [contentHeight, setContentHeight] = useState(0);
|
|
74
|
+
const [measured, setMeasured] = useState(false);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (!hasChildren)
|
|
77
|
+
return;
|
|
78
|
+
Animated.parallel([
|
|
79
|
+
Animated.timing(heightAnim, {
|
|
80
|
+
toValue: expanded ? 1 : 0,
|
|
81
|
+
duration: 250,
|
|
82
|
+
useNativeDriver: false,
|
|
83
|
+
}),
|
|
84
|
+
Animated.timing(chevronAnim, {
|
|
85
|
+
toValue: expanded ? 1 : 0,
|
|
86
|
+
duration: 250,
|
|
87
|
+
useNativeDriver: true,
|
|
88
|
+
}),
|
|
89
|
+
]).start();
|
|
90
|
+
}, [expanded, heightAnim, chevronAnim, hasChildren]);
|
|
91
|
+
const handlePress = useCallback(() => {
|
|
92
|
+
if (hasChildren) {
|
|
93
|
+
setExpanded(prev => !prev);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
item.onPress?.();
|
|
97
|
+
}
|
|
98
|
+
}, [hasChildren, item]);
|
|
99
|
+
const animatedHeight = heightAnim.interpolate({
|
|
100
|
+
inputRange: [0, 1],
|
|
101
|
+
outputRange: [0, contentHeight],
|
|
102
|
+
});
|
|
103
|
+
const chevronRotate = chevronAnim.interpolate({
|
|
104
|
+
inputRange: [0, 1],
|
|
105
|
+
outputRange: ['0deg', '180deg'],
|
|
106
|
+
});
|
|
107
|
+
return (_jsxs(View, { children: [_jsxs(Pressable, { onPress: handlePress, style: ({ pressed }) => [
|
|
108
|
+
styles.menuItem,
|
|
109
|
+
{
|
|
110
|
+
borderColor: itemColor,
|
|
111
|
+
borderTopColor: itemColor,
|
|
112
|
+
backgroundColor: isActive
|
|
113
|
+
? `${itemColor}20`
|
|
114
|
+
: DTColors.dark,
|
|
115
|
+
paddingLeft: 16 + level * 16,
|
|
116
|
+
opacity: pressed ? 0.7 : 1,
|
|
117
|
+
},
|
|
118
|
+
], children: [_jsx(Text, { style: [styles.menuItemTitle, { color: itemColor }], children: item.title }), hasChildren && (_jsx(Animated.View, { style: [
|
|
119
|
+
styles.chevron,
|
|
120
|
+
{ transform: [{ rotate: chevronRotate }] },
|
|
121
|
+
], children: _jsx(View, { style: [styles.chevronArrow, { borderTopColor: itemColor }] }) }))] }), hasChildren && (_jsx(Animated.View, { style: {
|
|
122
|
+
height: measured ? animatedHeight : undefined,
|
|
123
|
+
overflow: 'hidden',
|
|
124
|
+
}, children: _jsx(View, { onLayout: e => {
|
|
125
|
+
const h = e.nativeEvent.layout.height;
|
|
126
|
+
if (h > 0 && !measured) {
|
|
127
|
+
setContentHeight(h);
|
|
128
|
+
setMeasured(true);
|
|
129
|
+
if (!expanded) {
|
|
130
|
+
heightAnim.setValue(0);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}, children: item.items?.map(child => (_jsx(DTMenuItemRow, { item: child, variant: variant, activeVariant: activeVariant, level: level + 1 }, child.id))) }) }))] }));
|
|
134
|
+
}
|
|
135
|
+
const styles = StyleSheet.create({
|
|
136
|
+
container: {
|
|
137
|
+
gap: 4,
|
|
138
|
+
},
|
|
139
|
+
horizontal: {
|
|
140
|
+
flexDirection: 'row',
|
|
141
|
+
flexWrap: 'wrap',
|
|
142
|
+
},
|
|
143
|
+
vertical: {
|
|
144
|
+
flexDirection: 'column',
|
|
145
|
+
},
|
|
146
|
+
menuItem: {
|
|
147
|
+
flexDirection: 'row',
|
|
148
|
+
alignItems: 'center',
|
|
149
|
+
justifyContent: 'space-between',
|
|
150
|
+
borderWidth: 1,
|
|
151
|
+
borderTopWidth: 5,
|
|
152
|
+
paddingVertical: 12,
|
|
153
|
+
paddingRight: 16,
|
|
154
|
+
},
|
|
155
|
+
menuItemTitle: {
|
|
156
|
+
fontWeight: '600',
|
|
157
|
+
letterSpacing: 0.5,
|
|
158
|
+
textTransform: 'uppercase',
|
|
159
|
+
fontSize: 14,
|
|
160
|
+
},
|
|
161
|
+
chevron: {
|
|
162
|
+
justifyContent: 'center',
|
|
163
|
+
alignItems: 'center',
|
|
164
|
+
width: 24,
|
|
165
|
+
height: 24,
|
|
166
|
+
},
|
|
167
|
+
chevronArrow: {
|
|
168
|
+
width: 0,
|
|
169
|
+
height: 0,
|
|
170
|
+
borderLeftWidth: 5,
|
|
171
|
+
borderRightWidth: 5,
|
|
172
|
+
borderTopWidth: 7,
|
|
173
|
+
borderLeftColor: 'transparent',
|
|
174
|
+
borderRightColor: 'transparent',
|
|
175
|
+
},
|
|
176
|
+
dropdownContent: {
|
|
177
|
+
borderWidth: 2,
|
|
178
|
+
borderRadius: 0,
|
|
179
|
+
backgroundColor: DTColors.dark,
|
|
180
|
+
},
|
|
181
|
+
dropdownItem: {
|
|
182
|
+
borderRadius: 0,
|
|
183
|
+
},
|
|
184
|
+
dropdownItemTitle: {
|
|
185
|
+
letterSpacing: 0.3,
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
//# sourceMappingURL=DTMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTMenu.js","sourceRoot":"","sources":["../../src/components/DTMenu.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAC/D,OAAO,EACL,UAAU,EACV,IAAI,EAGJ,SAAS,EACT,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAiB,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAmDvE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,KAAK,EACL,OAAO,GAAG,QAAQ,EAClB,aAAa,GAAG,UAAU,EAC1B,MAAM,GAAG,UAAU,EACnB,KAAK,GACO;IACZ,OAAO,CACL,KAAC,IAAI,IACH,KAAK,EAAE;YACL,MAAM,CAAC,SAAS;YAChB,MAAM,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ;YAC7D,KAAK;SACN,YACA,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CACjB,KAAC,aAAa,IAEZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,CAAC,IAJH,IAAI,CAAC,EAAE,CAKZ,CACH,CAAC,GACG,CACR,CAAC;AACJ,CAAC;AAiCD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,EAC7B,KAAK,EACL,OAAO,GAAG,QAAQ,EACl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B,eAAe,EAAE,EAAE;QACnB,YAAY,EAAE,EAAE;KACjB;IACD,aAAa,EAAE;QACb,UAAU,EAAE,KAAK;QACjB,aAAa,EAAE,GAAG;QAClB,aAAa,EAAE,WAAW;QAC1B,QAAQ,EAAE,EAAE;KACb;IACD,OAAO,EAAE;QACP,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;QACpB,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;KACX;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,eAAe,EAAE,CAAC;QAClB,gBAAgB,EAAE,CAAC;QACnB,cAAc,EAAE,CAAC;QACjB,eAAe,EAAE,aAAa;QAC9B,gBAAgB,EAAE,aAAa;KAChC;IACD,eAAe,EAAE;QACf,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,CAAC;QACf,eAAe,EAAE,QAAQ,CAAC,IAAI;KAC/B;IACD,YAAY,EAAE;QACZ,YAAY,EAAE,CAAC;KAChB;IACD,iBAAiB,EAAE;QACjB,aAAa,EAAE,GAAG;KACnB;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DT Modal Component
|
|
3
|
+
*
|
|
4
|
+
* Wraps React Native Paper's Modal + Portal with the Dangerous Things
|
|
5
|
+
* aesthetic. Content is rendered inside a DTCard for the beveled look.
|
|
6
|
+
*
|
|
7
|
+
* Web CSS reference (Modal.tsx):
|
|
8
|
+
* - Centered overlay with dark backdrop
|
|
9
|
+
* - Content in beveled card container
|
|
10
|
+
*/
|
|
11
|
+
import { ViewStyle, StyleProp } from 'react-native';
|
|
12
|
+
import { type DTVariant } from '../utils/variantColors';
|
|
13
|
+
interface DTModalProps {
|
|
14
|
+
/**
|
|
15
|
+
* Whether the modal is visible
|
|
16
|
+
*/
|
|
17
|
+
visible: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Called when the modal is dismissed
|
|
20
|
+
*/
|
|
21
|
+
onDismiss: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Optional title for the modal header
|
|
24
|
+
*/
|
|
25
|
+
title?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Visual variant
|
|
28
|
+
* @default 'normal'
|
|
29
|
+
*/
|
|
30
|
+
variant?: DTVariant;
|
|
31
|
+
/**
|
|
32
|
+
* Modal content
|
|
33
|
+
*/
|
|
34
|
+
children: React.ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the modal can be dismissed by tapping the backdrop
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
dismissable?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Additional styles for the card content area
|
|
42
|
+
*/
|
|
43
|
+
contentStyle?: StyleProp<ViewStyle>;
|
|
44
|
+
/**
|
|
45
|
+
* Additional styles for the modal container
|
|
46
|
+
*/
|
|
47
|
+
style?: StyleProp<ViewStyle>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* DT-styled Modal wrapping React Native Paper Modal + Portal
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* <DTModal visible={showModal} onDismiss={() => setShowModal(false)} title="Confirm">
|
|
54
|
+
* <Text>Are you sure?</Text>
|
|
55
|
+
* </DTModal>
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* <DTModal visible={isOpen} onDismiss={close} variant="warning" title="Error">
|
|
59
|
+
* <Text>Something went wrong</Text>
|
|
60
|
+
* </DTModal>
|
|
61
|
+
*/
|
|
62
|
+
export declare function DTModal({ visible, onDismiss, title, variant, children, dismissable, contentStyle, style, }: DTModalProps): import("react/jsx-runtime").JSX.Element;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=DTModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTModal.d.ts","sourceRoot":"","sources":["../../src/components/DTModal.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAa,SAAS,EAAE,SAAS,EAAiC,MAAM,cAAc,CAAC;AAG9F,OAAO,EAAC,KAAK,SAAS,EAAC,MAAM,wBAAwB,CAAC;AAGtD,UAAU,YAAY;IACpB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,SAAS,EACT,KAAK,EACL,OAAkB,EAClB,QAAQ,EACR,WAAkB,EAClB,YAAY,EACZ,KAAK,GACN,EAAE,YAAY,2CA4Bd"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* DT Modal Component
|
|
4
|
+
*
|
|
5
|
+
* Wraps React Native Paper's Modal + Portal with the Dangerous Things
|
|
6
|
+
* aesthetic. Content is rendered inside a DTCard for the beveled look.
|
|
7
|
+
*
|
|
8
|
+
* Web CSS reference (Modal.tsx):
|
|
9
|
+
* - Centered overlay with dark backdrop
|
|
10
|
+
* - Content in beveled card container
|
|
11
|
+
*/
|
|
12
|
+
import { StyleSheet, KeyboardAvoidingView, Platform } from 'react-native';
|
|
13
|
+
import { Portal, Modal } from 'react-native-paper';
|
|
14
|
+
import { DTColors } from '../theme/colors';
|
|
15
|
+
import { DTCard } from './DTCard';
|
|
16
|
+
/**
|
|
17
|
+
* DT-styled Modal wrapping React Native Paper Modal + Portal
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* <DTModal visible={showModal} onDismiss={() => setShowModal(false)} title="Confirm">
|
|
21
|
+
* <Text>Are you sure?</Text>
|
|
22
|
+
* </DTModal>
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* <DTModal visible={isOpen} onDismiss={close} variant="warning" title="Error">
|
|
26
|
+
* <Text>Something went wrong</Text>
|
|
27
|
+
* </DTModal>
|
|
28
|
+
*/
|
|
29
|
+
export function DTModal({ visible, onDismiss, title, variant = 'normal', children, dismissable = true, contentStyle, style, }) {
|
|
30
|
+
return (_jsx(Portal, { children: _jsx(Modal, { visible: visible, onDismiss: onDismiss, dismissable: dismissable, contentContainerStyle: [styles.container, style], style: styles.modal, theme: {
|
|
31
|
+
colors: {
|
|
32
|
+
backdrop: DTColors.overlay,
|
|
33
|
+
},
|
|
34
|
+
}, children: _jsx(KeyboardAvoidingView, { behavior: Platform.OS === 'ios' ? 'padding' : undefined, style: styles.keyboardAvoid, children: _jsx(DTCard, { mode: variant, title: title, showHeader: !!title, contentStyle: contentStyle, children: children }) }) }) }));
|
|
35
|
+
}
|
|
36
|
+
const styles = StyleSheet.create({
|
|
37
|
+
modal: {},
|
|
38
|
+
container: {
|
|
39
|
+
marginHorizontal: 24,
|
|
40
|
+
},
|
|
41
|
+
keyboardAvoid: {
|
|
42
|
+
width: '100%',
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=DTModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTModal.js","sourceRoot":"","sources":["../../src/components/DTModal.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAC,UAAU,EAAwB,oBAAoB,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAC9F,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,o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per's ProgressBar
|
|
5
|
+
* with the Dangerous Things angular aesthetic.
|
|
6
|
+
*
|
|
7
|
+
* Web CSS reference (.progress / .progress-indicator):
|
|
8
|
+
* - Vertical or horizontal bar showing progress 0-100%
|
|
9
|
+
* - Mode-colored fill
|
|
10
|
+
*/
|
|
11
|
+
import { ViewStyle, StyleProp } from 'react-native';
|
|
12
|
+
import { type DTVariant } from '../utils/variantColors';
|
|
13
|
+
interface DTProgressBarProps {
|
|
14
|
+
/**
|
|
15
|
+
* Progress value between 0 and 1
|
|
16
|
+
*/
|
|
17
|
+
value: number;
|
|
18
|
+
/**
|
|
19
|
+
* Visual variant
|
|
20
|
+
* @default 'normal'
|
|
21
|
+
*/
|
|
22
|
+
variant?: DTVariant;
|
|
23
|
+
/**
|
|
24
|
+
* Orientation of the bar
|
|
25
|
+
* @default 'horizontal'
|
|
26
|
+
*/
|
|
27
|
+
orientation?: 'horizontal' | 'vertical';
|
|
28
|
+
/**
|
|
29
|
+
* Bar thickness in pixels
|
|
30
|
+
* @default 4
|
|
31
|
+
*/
|
|
32
|
+
height?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to animate progress changes
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
animated?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Show percentage label
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
showLabel?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Custom color (overrides variant)
|
|
45
|
+
*/
|
|
46
|
+
color?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Additional styles
|
|
49
|
+
*/
|
|
50
|
+
style?: StyleProp<ViewStyle>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* DT-styled ProgressBar wrapping React Native Paper ProgressBar
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* <DTProgressBar value={0.75} variant="normal" />
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* <DTProgressBar value={0.5} variant="emphasis" showLabel />
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* <DTProgressBar value={0.3} orientation="vertical" height={100} variant="success" />
|
|
63
|
+
*/
|
|
64
|
+
export declare function DTProgressBar({ value, variant, orientation, height, animated: _animated, showLabel, color, style, }: DTProgressBarProps): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=DTProgressBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTProgressBar.d.ts","sourceRoot":"","sources":["../../src/components/DTProgressBar.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAmB,SAAS,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAGpE,OAAO,EAAC,KAAK,SAAS,EAAkB,MAAM,wBAAwB,CAAC;AAGvE,UAAU,kBAAkB;IAC1B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACxC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,OAAkB,EAClB,WAA0B,EAC1B,MAAU,EACV,QAAQ,EAAE,SAAgB,EAC1B,SAAiB,EACjB,KAAK,EACL,KAAK,GACN,EAAE,kBAAkB,2CAmCpB"}
|