@tldiagram/core-ui 2.0.5 → 2.0.6
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/index.js +3094 -3043
- package/package.json +1 -1
- package/src/components/ElementPanel.tsx +86 -54
- package/src/components/SlidingPanel.tsx +0 -2
- package/src/pages/AppearanceSettings.tsx +47 -31
package/package.json
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
Box,
|
|
7
7
|
Button,
|
|
8
8
|
CloseButton,
|
|
9
|
-
Divider,
|
|
10
9
|
FormControl,
|
|
11
10
|
FormLabel,
|
|
12
11
|
HStack,
|
|
@@ -1034,49 +1033,87 @@ function ElementPanel({ isOpen, onClose, element, onSave, autoSave = false, onDe
|
|
|
1034
1033
|
|
|
1035
1034
|
{elementPanelAfterContentSlot}
|
|
1036
1035
|
|
|
1037
|
-
{element && (onPromoteVisibility || onDemoteVisibility || onResetVisibility) && (
|
|
1038
|
-
<Box borderTop="1px solid" borderColor="whiteAlpha.100" pt={
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
{visibilityOverrideDelta
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1036
|
+
{(element && (onPromoteVisibility || onDemoteVisibility || onResetVisibility)) || (isEdit && canEdit && onMerge) ? (
|
|
1037
|
+
<Box borderTop="1px solid" borderColor="whiteAlpha.100" pt={4} pb={1}>
|
|
1038
|
+
{element && (onPromoteVisibility || onDemoteVisibility || onResetVisibility) && (
|
|
1039
|
+
<>
|
|
1040
|
+
<HStack justify="space-between" mb={2}>
|
|
1041
|
+
<FormLabel fontSize="xs" fontWeight="semibold" letterSpacing="wider" color="gray.500" mb={0} textTransform="uppercase">Density</FormLabel>
|
|
1042
|
+
{visibilityOverrideDelta !== 0 && (
|
|
1043
|
+
<Badge colorScheme={visibilityOverrideDelta > 0 ? 'teal' : 'orange'} variant="subtle" fontSize="xs">
|
|
1044
|
+
{visibilityOverrideDelta > 0 ? `+${visibilityOverrideDelta}` : visibilityOverrideDelta}
|
|
1045
|
+
</Badge>
|
|
1046
|
+
)}
|
|
1047
|
+
</HStack>
|
|
1048
|
+
<HStack spacing={2} mb={isEdit && canEdit && onMerge ? 2 : 0}>
|
|
1049
|
+
<Button
|
|
1050
|
+
variant="outline"
|
|
1051
|
+
size="sm"
|
|
1052
|
+
borderColor="teal.700"
|
|
1053
|
+
color="teal.300"
|
|
1054
|
+
_hover={{ bg: 'teal.900', borderColor: 'teal.500', color: 'teal.100' }}
|
|
1055
|
+
onClick={() => onPromoteVisibility?.(element.id)}
|
|
1056
|
+
flex={1}
|
|
1057
|
+
isDisabled={isReadOnly}
|
|
1058
|
+
>
|
|
1059
|
+
Promote
|
|
1060
|
+
</Button>
|
|
1061
|
+
<Button
|
|
1062
|
+
variant="outline"
|
|
1063
|
+
size="sm"
|
|
1064
|
+
borderColor="orange.700"
|
|
1065
|
+
color="orange.300"
|
|
1066
|
+
_hover={{ bg: 'orange.900', borderColor: 'orange.500', color: 'orange.100' }}
|
|
1067
|
+
onClick={() => onDemoteVisibility?.(element.id)}
|
|
1068
|
+
flex={1}
|
|
1069
|
+
isDisabled={isReadOnly}
|
|
1070
|
+
>
|
|
1071
|
+
Demote
|
|
1072
|
+
</Button>
|
|
1073
|
+
{visibilityOverrideDelta !== 0 && (
|
|
1074
|
+
<Button variant="ghost" size="sm" color="gray.400" _hover={{ bg: 'whiteAlpha.100', color: 'white' }} onClick={() => onResetVisibility?.(element.id)} isDisabled={isReadOnly}>
|
|
1075
|
+
Reset
|
|
1076
|
+
</Button>
|
|
1077
|
+
)}
|
|
1078
|
+
</HStack>
|
|
1079
|
+
</>
|
|
1080
|
+
)}
|
|
1081
|
+
{isEdit && canEdit && onMerge && (
|
|
1082
|
+
<Button
|
|
1083
|
+
variant="outline"
|
|
1084
|
+
size="sm"
|
|
1085
|
+
borderColor="teal.700"
|
|
1086
|
+
color="teal.300"
|
|
1087
|
+
_hover={{ bg: 'teal.900', borderColor: 'teal.500', color: 'teal.100' }}
|
|
1088
|
+
onClick={() => onMerge(element.id)}
|
|
1089
|
+
w="full"
|
|
1090
|
+
>
|
|
1091
|
+
Merge
|
|
1053
1092
|
</Button>
|
|
1054
|
-
|
|
1055
|
-
<Button variant="ghost" size="sm" onClick={() => onResetVisibility?.(element.id)} isDisabled={isReadOnly}>
|
|
1056
|
-
Reset
|
|
1057
|
-
</Button>
|
|
1058
|
-
)}
|
|
1059
|
-
</HStack>
|
|
1060
|
-
</Box>
|
|
1061
|
-
)}
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
{isEdit && canEdit && onMerge && (
|
|
1066
|
-
<Box borderTop="1px solid" borderColor="whiteAlpha.100" pt={2}>
|
|
1067
|
-
<Button variant="subtle" size="sm" color="teal.200" _hover={{ bg: 'teal.900', color: 'teal.100' }}
|
|
1068
|
-
onClick={() => onMerge(element.id)} w="full">
|
|
1069
|
-
Merge
|
|
1070
|
-
</Button>
|
|
1093
|
+
)}
|
|
1071
1094
|
</Box>
|
|
1072
|
-
)}
|
|
1095
|
+
) : null}
|
|
1073
1096
|
|
|
1074
1097
|
{isEdit && canEdit && (
|
|
1075
|
-
<HStack borderTop="1px solid" borderColor="whiteAlpha.100" pt={
|
|
1076
|
-
<Button
|
|
1098
|
+
<HStack borderTop="1px solid" borderColor="whiteAlpha.100" pt={4} pb={1} spacing={2}>
|
|
1099
|
+
<Button
|
|
1100
|
+
variant="ghost"
|
|
1101
|
+
size="sm"
|
|
1102
|
+
color="gray.400"
|
|
1103
|
+
_hover={{ bg: 'whiteAlpha.100', color: 'white' }}
|
|
1104
|
+
onClick={handleDelete}
|
|
1105
|
+
flex={1}
|
|
1106
|
+
>
|
|
1077
1107
|
Remove
|
|
1078
1108
|
</Button>
|
|
1079
|
-
<Button
|
|
1109
|
+
<Button
|
|
1110
|
+
variant="ghost"
|
|
1111
|
+
size="sm"
|
|
1112
|
+
color="red.400"
|
|
1113
|
+
_hover={{ bg: 'red.900', color: 'red.200' }}
|
|
1114
|
+
onClick={confirmPermanentDelete.onOpen}
|
|
1115
|
+
flex={1}
|
|
1116
|
+
>
|
|
1080
1117
|
Delete Element
|
|
1081
1118
|
</Button>
|
|
1082
1119
|
</HStack>
|
|
@@ -1084,24 +1121,19 @@ function ElementPanel({ isOpen, onClose, element, onSave, autoSave = false, onDe
|
|
|
1084
1121
|
</VStack>
|
|
1085
1122
|
</ScrollIndicatorWrapper>
|
|
1086
1123
|
|
|
1087
|
-
<Divider borderColor="whiteAlpha.100" />
|
|
1088
|
-
|
|
1089
1124
|
{/* Footer */}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1125
|
+
{!autoSaveEdit && (
|
|
1126
|
+
<HStack px={4} py={3} justify="flex-end" flexShrink={0}>
|
|
1127
|
+
<Button variant="ghost" size="sm" onClick={handleClose}>
|
|
1128
|
+
Cancel
|
|
1129
|
+
</Button>
|
|
1130
|
+
{canEdit && (
|
|
1131
|
+
<Button size="sm" px={5} colorScheme="blue" onClick={handleSave} isLoading={loading}>
|
|
1132
|
+
Save
|
|
1096
1133
|
</Button>
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
</Button>
|
|
1101
|
-
)}
|
|
1102
|
-
</HStack>
|
|
1103
|
-
)}
|
|
1104
|
-
</HStack>
|
|
1134
|
+
)}
|
|
1135
|
+
</HStack>
|
|
1136
|
+
)}
|
|
1105
1137
|
</SlidingPanel>
|
|
1106
1138
|
|
|
1107
1139
|
<ConfirmDialog
|
|
@@ -1,46 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
Button,
|
|
4
|
+
FormLabel,
|
|
5
|
+
HStack,
|
|
6
|
+
Menu,
|
|
7
|
+
MenuButton,
|
|
8
|
+
MenuItem,
|
|
9
|
+
MenuList,
|
|
10
|
+
Text,
|
|
11
|
+
Tooltip,
|
|
12
|
+
VStack,
|
|
13
|
+
Wrap,
|
|
14
|
+
WrapItem,
|
|
15
|
+
} from '@chakra-ui/react'
|
|
2
16
|
import { ACCENT_OPTIONS, BACKGROUND_OPTIONS, ELEMENT_OPTIONS } from '../constants/colors'
|
|
3
17
|
import { useTheme } from '../context/ThemeContext'
|
|
4
18
|
import { useSourceEditor } from '../utils/sourceEditor'
|
|
5
|
-
import
|
|
19
|
+
import { ChevronDownIcon } from '../components/Icons'
|
|
6
20
|
|
|
7
21
|
export default function AppearanceSettings({ compact = false }: { compact?: boolean }) {
|
|
8
22
|
const { accent, setAccent, background, setBackground, elementColor, setElementColor } = useTheme()
|
|
9
23
|
const { editor, setEditor } = useSourceEditor()
|
|
10
|
-
const swatchSize = compact ? '
|
|
24
|
+
const swatchSize = compact ? '21px' : '32px'
|
|
11
25
|
const sectionGap = compact ? 5 : 8
|
|
12
26
|
|
|
13
27
|
return (
|
|
14
28
|
<VStack align="start" spacing={sectionGap} maxW={compact ? '320px' : '480px'} w="full">
|
|
15
|
-
<Box w="full">
|
|
16
|
-
<HStack justify="space-between" align="end" w="full" mb={compact ? 0 : 1}>
|
|
17
|
-
<Box>
|
|
18
|
-
<Text fontFamily="heading" fontSize={compact ? 'md' : 'lg'} fontWeight="bold" color="gray.100" mb={1}>
|
|
19
|
-
Theme
|
|
20
|
-
</Text>
|
|
21
|
-
</Box>
|
|
22
|
-
</HStack>
|
|
23
|
-
</Box>
|
|
24
29
|
|
|
25
|
-
<Box w="full">
|
|
26
|
-
<FormLabel mb={3} fontSize={compact ? 'xs' : 'sm'} textTransform="uppercase" letterSpacing="0.12em" color="gray.400">
|
|
27
|
-
Source Editor
|
|
28
|
-
</FormLabel>
|
|
29
|
-
<Select
|
|
30
|
-
size="sm"
|
|
31
|
-
value={editor}
|
|
32
|
-
onChange={(event) => setEditor(event.target.value as SourceEditor)}
|
|
33
|
-
bg="whiteAlpha.50"
|
|
34
|
-
borderColor="whiteAlpha.200"
|
|
35
|
-
color="gray.100"
|
|
36
|
-
maxW="220px"
|
|
37
|
-
_hover={{ borderColor: 'whiteAlpha.400' }}
|
|
38
|
-
_focus={{ borderColor: 'blue.400', boxShadow: '0 0 0 1px var(--chakra-colors-blue-400)' }}
|
|
39
|
-
>
|
|
40
|
-
<option value="zed">Zed</option>
|
|
41
|
-
<option value="vscode">VS Code</option>
|
|
42
|
-
</Select>
|
|
43
|
-
</Box>
|
|
44
30
|
|
|
45
31
|
<Box w="full">
|
|
46
32
|
<FormLabel mb={3} fontSize={compact ? 'xs' : 'sm'} textTransform="uppercase" letterSpacing="0.12em" color="gray.400">
|
|
@@ -153,6 +139,36 @@ export default function AppearanceSettings({ compact = false }: { compact?: bool
|
|
|
153
139
|
})}
|
|
154
140
|
</Wrap>
|
|
155
141
|
</Box>
|
|
142
|
+
|
|
143
|
+
<Box w="full">
|
|
144
|
+
<FormLabel mb={3} fontSize={compact ? 'xs' : 'sm'} textTransform="uppercase" letterSpacing="0.12em" color="gray.400">
|
|
145
|
+
Editor
|
|
146
|
+
</FormLabel>
|
|
147
|
+
<Menu>
|
|
148
|
+
<MenuButton
|
|
149
|
+
as={Button}
|
|
150
|
+
size="sm"
|
|
151
|
+
variant="clay"
|
|
152
|
+
rightIcon={<ChevronDownIcon size={12} strokeWidth={4} />}
|
|
153
|
+
minW="140px"
|
|
154
|
+
textAlign="left"
|
|
155
|
+
bg="whiteAlpha.100"
|
|
156
|
+
color="gray.100"
|
|
157
|
+
_hover={{ bg: 'whiteAlpha.200' }}
|
|
158
|
+
_active={{ bg: 'whiteAlpha.300' }}
|
|
159
|
+
>
|
|
160
|
+
{editor === 'zed' ? 'Zed' : 'VS Code'}
|
|
161
|
+
</MenuButton>
|
|
162
|
+
<MenuList>
|
|
163
|
+
<MenuItem onClick={() => setEditor('zed')} fontWeight={editor === 'zed' ? 'bold' : 'normal'}>
|
|
164
|
+
Zed
|
|
165
|
+
</MenuItem>
|
|
166
|
+
<MenuItem onClick={() => setEditor('vscode')} fontWeight={editor === 'vscode' ? 'bold' : 'normal'}>
|
|
167
|
+
VS Code
|
|
168
|
+
</MenuItem>
|
|
169
|
+
</MenuList>
|
|
170
|
+
</Menu>
|
|
171
|
+
</Box>
|
|
156
172
|
</VStack>
|
|
157
173
|
)
|
|
158
174
|
}
|