@mongodb-js/compass-components 1.68.0 → 1.70.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/breadcrumb.d.ts.map +1 -1
- package/dist/components/breadcrumb.js +3 -2
- package/dist/components/bson-value.d.ts +23 -12
- package/dist/components/bson-value.d.ts.map +1 -1
- package/dist/components/bson-value.js +43 -63
- package/dist/components/compass-components-provider.d.ts +6 -8
- package/dist/components/compass-components-provider.d.ts.map +1 -1
- package/dist/components/compass-components-provider.js +5 -5
- package/dist/components/context-menu.d.ts +1 -2
- package/dist/components/context-menu.d.ts.map +1 -1
- package/dist/components/context-menu.js +5 -2
- package/dist/components/document-list/bson-display-options-context.d.ts +13 -0
- package/dist/components/document-list/bson-display-options-context.d.ts.map +1 -0
- package/dist/components/document-list/bson-display-options-context.js +56 -0
- package/dist/components/document-list/bson-utils.d.ts +10 -0
- package/dist/components/document-list/bson-utils.d.ts.map +1 -0
- package/dist/components/document-list/bson-utils.js +63 -0
- package/dist/components/document-list/date-time-picker.d.ts +6 -0
- package/dist/components/document-list/date-time-picker.d.ts.map +1 -0
- package/dist/components/document-list/date-time-picker.js +112 -0
- package/dist/components/document-list/date-with-timezone-hint.d.ts +11 -0
- package/dist/components/document-list/date-with-timezone-hint.d.ts.map +1 -0
- package/dist/components/document-list/date-with-timezone-hint.js +95 -0
- package/dist/components/document-list/document-edit-actions-footer.d.ts +1 -0
- package/dist/components/document-list/document-edit-actions-footer.d.ts.map +1 -1
- package/dist/components/document-list/document-edit-actions-footer.js +2 -5
- package/dist/components/document-list/document.d.ts.map +1 -1
- package/dist/components/document-list/document.js +8 -0
- package/dist/components/document-list/editors/date-editor.d.ts +4 -0
- package/dist/components/document-list/editors/date-editor.d.ts.map +1 -0
- package/dist/components/document-list/editors/date-editor.js +135 -0
- package/dist/components/document-list/editors/default-editor.d.ts +4 -0
- package/dist/components/document-list/editors/default-editor.d.ts.map +1 -0
- package/dist/components/document-list/editors/default-editor.js +46 -0
- package/dist/components/document-list/editors/editor-with-label.d.ts +7 -0
- package/dist/components/document-list/editors/editor-with-label.d.ts.map +1 -0
- package/dist/components/document-list/editors/editor-with-label.js +28 -0
- package/dist/components/document-list/editors/input-editor.d.ts +4 -0
- package/dist/components/document-list/editors/input-editor.d.ts.map +1 -0
- package/dist/components/document-list/editors/input-editor.js +24 -0
- package/dist/components/document-list/editors/shared.d.ts +16 -0
- package/dist/components/document-list/editors/shared.d.ts.map +1 -0
- package/dist/components/document-list/editors/shared.js +34 -0
- package/dist/components/document-list/editors/text-editor.d.ts +4 -0
- package/dist/components/document-list/editors/text-editor.d.ts.map +1 -0
- package/dist/components/document-list/editors/text-editor.js +85 -0
- package/dist/components/document-list/editors/uuid-editor.d.ts +4 -0
- package/dist/components/document-list/editors/uuid-editor.d.ts.map +1 -0
- package/dist/components/document-list/editors/uuid-editor.js +54 -0
- package/dist/components/document-list/element-editors.d.ts +1 -1
- package/dist/components/document-list/element-editors.d.ts.map +1 -1
- package/dist/components/document-list/element-editors.js +56 -135
- package/dist/components/document-list/element.d.ts.map +1 -1
- package/dist/components/document-list/element.js +114 -39
- package/dist/components/document-list/field-drag.d.ts +27 -0
- package/dist/components/document-list/field-drag.d.ts.map +1 -0
- package/dist/components/document-list/field-drag.js +40 -0
- package/dist/components/document-list/index.d.ts +2 -1
- package/dist/components/document-list/index.d.ts.map +1 -1
- package/dist/components/document-list/index.js +8 -3
- package/dist/components/document-list/visible-field-toggle.d.ts.map +1 -1
- package/dist/components/document-list/visible-field-toggle.js +2 -0
- package/dist/components/drawer-portal.d.ts +4 -2
- package/dist/components/drawer-portal.d.ts.map +1 -1
- package/dist/components/error-boundary.d.ts +1 -0
- package/dist/components/error-boundary.d.ts.map +1 -1
- package/dist/components/file-picker-dialog.d.ts +1 -0
- package/dist/components/file-picker-dialog.d.ts.map +1 -1
- package/dist/components/guide-cue/guide-cue.d.ts +2 -1
- package/dist/components/guide-cue/guide-cue.d.ts.map +1 -1
- package/dist/components/guide-cue/guide-cue.js +10 -0
- package/dist/components/inline-definition.js +2 -2
- package/dist/components/leafygreen.d.ts +1 -35
- package/dist/components/leafygreen.d.ts.map +1 -1
- package/dist/components/links/link.d.ts +1 -1
- package/dist/components/links/link.d.ts.map +1 -1
- package/dist/components/modals/form-modal.d.ts +2 -1
- package/dist/components/modals/form-modal.d.ts.map +1 -1
- package/dist/components/modals/form-modal.js +2 -2
- package/dist/components/modals/modal-body.d.ts.map +1 -1
- package/dist/components/modals/modal-body.js +7 -0
- package/dist/components/resize-handle.d.ts.map +1 -1
- package/dist/components/resize-handle.js +5 -8
- package/dist/components/select-list.d.ts.map +1 -1
- package/dist/components/select-list.js +2 -2
- package/dist/components/signal-popover.d.ts +1 -1
- package/dist/components/signal-popover.d.ts.map +1 -1
- package/dist/components/signal-popover.js +2 -1
- package/dist/components/workspace-container.d.ts +2 -2
- package/dist/components/workspace-container.d.ts.map +1 -1
- package/dist/components/workspace-tabs/workspace-tabs.d.ts.map +1 -1
- package/dist/components/workspace-tabs/workspace-tabs.js +1 -1
- package/dist/hooks/use-confirmation.d.ts +3 -1
- package/dist/hooks/use-confirmation.d.ts.map +1 -1
- package/dist/hooks/use-confirmation.js +25 -15
- package/dist/hooks/use-copy-paste-context-menu.d.ts +1 -1
- package/dist/hooks/use-copy-paste-context-menu.d.ts.map +1 -1
- package/dist/hooks/use-stacked-component.d.ts.map +1 -1
- package/dist/hooks/use-theme.d.ts.map +1 -1
- package/dist/hooks/use-toast.d.ts +3 -1
- package/dist/hooks/use-toast.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/utils/format-date.d.ts +17 -0
- package/dist/utils/format-date.d.ts.map +1 -1
- package/dist/utils/format-date.js +33 -2
- package/dist/utils/nbsp.d.ts +9 -0
- package/dist/utils/nbsp.d.ts.map +1 -0
- package/dist/utils/nbsp.js +19 -0
- package/package.json +17 -17
- package/dist/components/document-list/legacy-uuid-format-context.d.ts +0 -4
- package/dist/components/document-list/legacy-uuid-format-context.d.ts.map +0 -1
- package/dist/components/document-list/legacy-uuid-format-context.js +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumb.d.ts","sourceRoot":"","sources":["../../src/components/breadcrumb.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"breadcrumb.d.ts","sourceRoot":"","sources":["../../src/components/breadcrumb.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAQxC,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AA2CF,eAAO,MAAM,WAAW,GAAI,uBAGzB;IACD,KAAK,EACD,cAAc,EAAE,GAChB,CAAC,GAAG,cAAc,EAAE,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,sBAqDA,CAAC"}
|
|
@@ -40,6 +40,7 @@ const emotion_1 = require("@leafygreen-ui/emotion");
|
|
|
40
40
|
const palette_1 = require("@leafygreen-ui/palette");
|
|
41
41
|
const use_theme_1 = require("../hooks/use-theme");
|
|
42
42
|
const leafygreen_1 = require("./leafygreen");
|
|
43
|
+
const nbsp_1 = require("../utils/nbsp");
|
|
43
44
|
const breadcrumbStyles = (0, emotion_1.css)({
|
|
44
45
|
display: 'flex',
|
|
45
46
|
gap: tokens_1.spacing[100],
|
|
@@ -84,9 +85,9 @@ const Breadcrumbs = ({ items, className, }) => {
|
|
|
84
85
|
clickableItems.map((item, index) => {
|
|
85
86
|
return (react_1.default.createElement(react_1.Fragment, { key: `${index}-${item.name}` },
|
|
86
87
|
react_1.default.createElement(leafygreen_1.Link, { as: "button", hideExternalIcon: true, className: (0, emotion_1.cx)(breadcrumbButtonStyles, textStyles), onClick: item.onClick, title: item.name },
|
|
87
|
-
react_1.default.createElement(leafygreen_1.Body, { className: (0, emotion_1.cx)(textStyles, darkMode ? itemDarkStyles : itemLightStyles) }, item.name)),
|
|
88
|
+
react_1.default.createElement(leafygreen_1.Body, { className: (0, emotion_1.cx)(textStyles, darkMode ? itemDarkStyles : itemLightStyles) }, (0, nbsp_1.nbsp)(item.name))),
|
|
88
89
|
react_1.default.createElement(leafygreen_1.Icon, { glyph: "ChevronRight", size: "small", color: palette_1.palette.gray.light1, className: iconStyles })));
|
|
89
90
|
}),
|
|
90
|
-
react_1.default.createElement(leafygreen_1.Body, { key: [items.length - 1, lastItem.name].join(''), className: (0, emotion_1.cx)(textStyles, darkMode ? lastItemStylesDark : lastItemStylesLight) }, lastItem.name)));
|
|
91
|
+
react_1.default.createElement(leafygreen_1.Body, { key: [items.length - 1, lastItem.name].join(''), className: (0, emotion_1.cx)(textStyles, darkMode ? lastItemStylesDark : lastItemStylesLight) }, (0, nbsp_1.nbsp)(lastItem.name))));
|
|
91
92
|
};
|
|
92
93
|
exports.Breadcrumbs = Breadcrumbs;
|
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { TypeCastMap } from 'hadron-type-checker';
|
|
3
3
|
import type { DBRef } from 'bson';
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
type: type;
|
|
7
|
-
value: TypeCastMap[type];
|
|
8
|
-
};
|
|
9
|
-
}[keyof TypeCastMap] | {
|
|
10
|
-
type: 'DBRef';
|
|
11
|
-
value: DBRef;
|
|
4
|
+
type ValueTypeMap = TypeCastMap & {
|
|
5
|
+
DBRef: DBRef;
|
|
12
6
|
};
|
|
13
|
-
type ValueTypes =
|
|
14
|
-
|
|
7
|
+
type ValueTypes = keyof ValueTypeMap;
|
|
8
|
+
/**
|
|
9
|
+
* ValueProps external interface is meant to provide a correlation between type
|
|
10
|
+
* and the type of value.
|
|
11
|
+
*
|
|
12
|
+
* So `T` is used to capture the type name and pick the corresponding type
|
|
13
|
+
* out of ValueTypeMap.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* function x<T extends ValueTypes>(props: ValueProps<T>) {}
|
|
18
|
+
* x({ type: 'String', value: 'example' });
|
|
19
|
+
* x({ type: 'Decimal128', value: 'test' }); // Error
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
type ValueProps<T extends ValueTypes = ValueTypes> = {
|
|
23
|
+
type: T;
|
|
24
|
+
value: ValueTypeMap[T];
|
|
25
|
+
};
|
|
26
|
+
export declare const BSONValueContainer: React.FunctionComponent<React.HTMLProps<HTMLSpanElement> & {
|
|
15
27
|
type?: ValueTypes;
|
|
16
|
-
chidren?: React.ReactChildren;
|
|
17
28
|
}>;
|
|
18
|
-
declare
|
|
29
|
+
declare function BSONValue<T extends ValueTypes>(genericProps: ValueProps<T>): React.JSX.Element;
|
|
19
30
|
export default BSONValue;
|
|
20
31
|
//# sourceMappingURL=bson-value.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bson-value.d.ts","sourceRoot":"","sources":["../../src/components/bson-value.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"bson-value.d.ts","sourceRoot":"","sources":["../../src/components/bson-value.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAalC,KAAK,YAAY,GAAG,WAAW,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEnD,KAAK,UAAU,GAAG,MAAM,YAAY,CAAC;AAErC;;;;;;;;;;;;;GAaG;AACH,KAAK,UAAU,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,IAAI;IACnD,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CACxB,CAAC;AAgDF,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,iBAAiB,CACtD,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,GAAG;IACjC,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAoBF,CAAC;AAqbF,iBAAS,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,qBAqDnE;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -38,60 +38,42 @@ const react_1 = __importStar(require("react"));
|
|
|
38
38
|
const hadron_type_checker_1 = require("hadron-type-checker");
|
|
39
39
|
const bson_1 = require("bson");
|
|
40
40
|
const mongodb_query_parser_1 = require("mongodb-query-parser");
|
|
41
|
-
const code_1 = require("@leafygreen-ui/code");
|
|
42
41
|
const leafygreen_1 = require("./leafygreen");
|
|
43
42
|
const tokens_1 = require("@leafygreen-ui/tokens");
|
|
44
43
|
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
45
|
-
const
|
|
46
|
-
const
|
|
44
|
+
const bson_utils_1 = require("./document-list/bson-utils");
|
|
45
|
+
const bson_display_options_context_1 = require("./document-list/bson-display-options-context");
|
|
46
|
+
const date_with_timezone_hint_1 = require("./document-list/date-with-timezone-hint");
|
|
47
47
|
function truncate(str, length = 70) {
|
|
48
48
|
const truncated = str.slice(0, length);
|
|
49
49
|
return length < str.length ? `${truncated}…` : str;
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
[use_theme_1.Themes.Light]: {
|
|
62
|
-
Int32: code_1.variantColors.light[9],
|
|
63
|
-
Double: code_1.variantColors.light[9],
|
|
64
|
-
Decimal128: code_1.variantColors.light[9],
|
|
65
|
-
Date: code_1.variantColors.light[9],
|
|
66
|
-
Boolean: code_1.variantColors.light[10],
|
|
67
|
-
String: code_1.variantColors.light[7],
|
|
68
|
-
ObjectId: code_1.variantColors.light[5],
|
|
69
|
-
},
|
|
70
|
-
};
|
|
51
|
+
function truncateLines(str, lines = 3) {
|
|
52
|
+
let index = -1;
|
|
53
|
+
for (let i = 0; i < lines; i++) {
|
|
54
|
+
const next = str.indexOf('\n', index + 1);
|
|
55
|
+
if (next === -1)
|
|
56
|
+
return str;
|
|
57
|
+
index = next;
|
|
58
|
+
}
|
|
59
|
+
return `${str.slice(0, index)}…`;
|
|
60
|
+
}
|
|
71
61
|
const bsonValue = (0, emotion_1.css)({
|
|
62
|
+
display: `var(${bson_utils_1.bsonValueDisplayVar}, block)`,
|
|
72
63
|
whiteSpace: 'nowrap',
|
|
73
64
|
overflow: 'hidden',
|
|
74
65
|
textOverflow: 'ellipsis',
|
|
75
66
|
});
|
|
76
67
|
const bsonValuePrewrap = (0, emotion_1.css)({
|
|
77
|
-
whiteSpace: 'pre
|
|
68
|
+
whiteSpace: 'pre',
|
|
78
69
|
});
|
|
70
|
+
// A span so that it stays valid markup whatever `bsonValueDisplayVar` resolves
|
|
71
|
+
// the display to, including inside the inline document list layout.
|
|
79
72
|
const BSONValueContainer = ({ type, children, className, ...props }) => {
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
if (!type) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
color: VALUE_COLOR_BY_THEME_AND_TYPE[darkMode ? use_theme_1.Themes.Dark : use_theme_1.Themes.Light][type],
|
|
87
|
-
};
|
|
88
|
-
}, [type, darkMode]);
|
|
89
|
-
return (react_1.default.createElement("div", { ...props, className: (0, emotion_1.cx)(className, bsonValue, type === 'String' && bsonValuePrewrap, `element-value element-value-is-${type ? type.toLowerCase() : 'unknown'}`), style: colorStyle }, children));
|
|
73
|
+
const bsonStyles = (0, bson_utils_1.useBsonThemeStyles)(type);
|
|
74
|
+
return (react_1.default.createElement("span", { ...props, className: (0, emotion_1.cx)(className, bsonValue, type === 'String' && bsonValuePrewrap, `element-value element-value-is-${type ? type.toLowerCase() : 'unknown'}`), style: bsonStyles }, children));
|
|
90
75
|
};
|
|
91
76
|
exports.BSONValueContainer = BSONValueContainer;
|
|
92
|
-
const nonSelectable = (0, emotion_1.css)({
|
|
93
|
-
userSelect: 'none',
|
|
94
|
-
});
|
|
95
77
|
const encryptedHelpLinkStyle = (0, emotion_1.css)({
|
|
96
78
|
color: 'inherit',
|
|
97
79
|
marginLeft: tokens_1.spacing[100],
|
|
@@ -100,28 +82,25 @@ const ObjectIdValue = ({ value, }) => {
|
|
|
100
82
|
const stringifiedValue = (0, react_1.useMemo)(() => {
|
|
101
83
|
return String(value);
|
|
102
84
|
}, [value]);
|
|
103
|
-
return (react_1.default.createElement(exports.BSONValueContainer, { type: "ObjectId", title: stringifiedValue },
|
|
104
|
-
react_1.default.createElement("span", { className: nonSelectable }, "ObjectId('"),
|
|
105
|
-
stringifiedValue,
|
|
106
|
-
react_1.default.createElement("span", { className: nonSelectable }, "')")));
|
|
85
|
+
return (react_1.default.createElement(exports.BSONValueContainer, { type: "ObjectId", title: stringifiedValue }, (0, bson_utils_1.wrapValueWithBsonLabel)('ObjectId', stringifiedValue)));
|
|
107
86
|
};
|
|
108
87
|
const toLegacyJavaUUID = ({ value }) => {
|
|
109
88
|
const hex = value.toString('hex');
|
|
110
89
|
const reversedHex = (0, hadron_type_checker_1.reverseJavaUUIDBytes)(hex);
|
|
111
|
-
return
|
|
90
|
+
return (0, bson_utils_1.wrapValueWithBsonLabel)('LegacyJavaUUID', (0, hadron_type_checker_1.uuidHexToString)(reversedHex));
|
|
112
91
|
};
|
|
113
92
|
const toLegacyCSharpUUID = ({ value }) => {
|
|
114
93
|
const hex = value.toString('hex');
|
|
115
94
|
const reversedHex = (0, hadron_type_checker_1.reverseCSharpUUIDBytes)(hex);
|
|
116
|
-
return
|
|
95
|
+
return (0, bson_utils_1.wrapValueWithBsonLabel)('LegacyCSharpUUID', (0, hadron_type_checker_1.uuidHexToString)(reversedHex));
|
|
117
96
|
};
|
|
118
97
|
const toLegacyPythonUUID = ({ value }) => {
|
|
119
98
|
const hex = value.toString('hex');
|
|
120
|
-
return
|
|
99
|
+
return (0, bson_utils_1.wrapValueWithBsonLabel)('LegacyPythonUUID', (0, hadron_type_checker_1.uuidHexToString)(hex));
|
|
121
100
|
};
|
|
122
101
|
// Binary sub_type 3.
|
|
123
102
|
const LegacyUUIDValue = (bsonValue) => {
|
|
124
|
-
const legacyUUIDDisplayEncoding = (0,
|
|
103
|
+
const { legacyUUIDDisplayEncoding } = (0, bson_display_options_context_1.useBSONDisplayOptions)();
|
|
125
104
|
const stringifiedValue = (0, react_1.useMemo)(() => {
|
|
126
105
|
// UUID must be exactly 16 bytes.
|
|
127
106
|
if (bsonValue.value.buffer.length === 16) {
|
|
@@ -167,17 +146,14 @@ const UUIDValue = ({ value, }) => {
|
|
|
167
146
|
return value.toString('hex');
|
|
168
147
|
}
|
|
169
148
|
}, [value]);
|
|
170
|
-
return (react_1.default.createElement(exports.BSONValueContainer, { type: "Binary", title: stringifiedValue },
|
|
171
|
-
react_1.default.createElement("span", { className: nonSelectable }, "UUID('"),
|
|
172
|
-
stringifiedValue,
|
|
173
|
-
react_1.default.createElement("span", { className: nonSelectable }, "')")));
|
|
149
|
+
return (react_1.default.createElement(exports.BSONValueContainer, { type: "Binary", title: stringifiedValue }, (0, bson_utils_1.wrapValueWithBsonLabel)('UUID', stringifiedValue)));
|
|
174
150
|
};
|
|
175
151
|
// Legacy Java UUID value component
|
|
176
152
|
const LegacyJavaUUIDValue = ({ value }) => {
|
|
177
153
|
const stringifiedValue = (0, react_1.useMemo)(() => {
|
|
178
154
|
// During editing, value might be a string
|
|
179
155
|
if (typeof value === 'string') {
|
|
180
|
-
return
|
|
156
|
+
return (0, bson_utils_1.wrapValueWithBsonLabel)('LegacyJavaUUID', value);
|
|
181
157
|
}
|
|
182
158
|
if (!value || !value.buffer) {
|
|
183
159
|
return String(value);
|
|
@@ -191,7 +167,7 @@ const LegacyCSharpUUIDValue = ({ value }) => {
|
|
|
191
167
|
const stringifiedValue = (0, react_1.useMemo)(() => {
|
|
192
168
|
// During editing, value might be a string
|
|
193
169
|
if (typeof value === 'string') {
|
|
194
|
-
return
|
|
170
|
+
return (0, bson_utils_1.wrapValueWithBsonLabel)('LegacyCSharpUUID', value);
|
|
195
171
|
}
|
|
196
172
|
if (!value || !value.buffer) {
|
|
197
173
|
return String(value);
|
|
@@ -205,7 +181,7 @@ const LegacyPythonUUIDValue = ({ value }) => {
|
|
|
205
181
|
const stringifiedValue = (0, react_1.useMemo)(() => {
|
|
206
182
|
// During editing, value might be a string
|
|
207
183
|
if (typeof value === 'string') {
|
|
208
|
-
return
|
|
184
|
+
return (0, bson_utils_1.wrapValueWithBsonLabel)('LegacyPythonUUID', value);
|
|
209
185
|
}
|
|
210
186
|
if (!value || !value.buffer) {
|
|
211
187
|
return String(value);
|
|
@@ -285,19 +261,20 @@ const DateValue = ({ value, }) => {
|
|
|
285
261
|
return String(value);
|
|
286
262
|
}
|
|
287
263
|
}, [value]);
|
|
288
|
-
return (react_1.default.createElement(
|
|
264
|
+
return (react_1.default.createElement(date_with_timezone_hint_1.DateWithTimezoneHint, { value: value },
|
|
265
|
+
react_1.default.createElement(exports.BSONValueContainer, { type: "Date", title: stringifiedValue }, (0, bson_utils_1.wrapValueWithBsonLabel)('Date', stringifiedValue))));
|
|
289
266
|
};
|
|
290
267
|
const NumberValue = ({ type, value }) => {
|
|
291
268
|
const stringifiedValue = (0, react_1.useMemo)(() => {
|
|
292
|
-
return String(value
|
|
293
|
-
}, [value]);
|
|
269
|
+
return (0, bson_utils_1.wrapValueWithBsonLabel)(type, String(value));
|
|
270
|
+
}, [value, type]);
|
|
294
271
|
return (react_1.default.createElement(exports.BSONValueContainer, { type: type, title: stringifiedValue }, stringifiedValue));
|
|
295
272
|
};
|
|
296
273
|
const StringValue = ({ value, }) => {
|
|
297
274
|
const truncatedValue = (0, react_1.useMemo)(() => {
|
|
298
|
-
return truncate(value,
|
|
275
|
+
return truncateLines(truncate(value, 1000));
|
|
299
276
|
}, [value]);
|
|
300
|
-
return (react_1.default.createElement(exports.BSONValueContainer, { type: "String", title:
|
|
277
|
+
return (react_1.default.createElement(exports.BSONValueContainer, { type: "String", title: truncatedValue },
|
|
301
278
|
"\"",
|
|
302
279
|
truncatedValue,
|
|
303
280
|
"\""));
|
|
@@ -322,8 +299,8 @@ const KeyValue = ({ type }) => {
|
|
|
322
299
|
};
|
|
323
300
|
const DBRefValue = ({ value, }) => {
|
|
324
301
|
const stringifiedValue = (0, react_1.useMemo)(() => {
|
|
325
|
-
return
|
|
326
|
-
}, [value
|
|
302
|
+
return (0, mongodb_query_parser_1.toJSString)(value, 0);
|
|
303
|
+
}, [value]);
|
|
327
304
|
return (react_1.default.createElement(exports.BSONValueContainer, { type: "DBRef", title: stringifiedValue }, stringifiedValue));
|
|
328
305
|
};
|
|
329
306
|
const SymbolValue = ({ value, }) => {
|
|
@@ -332,11 +309,11 @@ const SymbolValue = ({ value, }) => {
|
|
|
332
309
|
}, [value]);
|
|
333
310
|
return (react_1.default.createElement(exports.BSONValueContainer, { type: "BSONSymbol", title: stringifiedValue }, stringifiedValue));
|
|
334
311
|
};
|
|
335
|
-
const UnknownValue = ({ value }) => {
|
|
312
|
+
const UnknownValue = ({ value, type }) => {
|
|
336
313
|
const stringifiedValue = (0, react_1.useMemo)(() => {
|
|
337
314
|
return String(value);
|
|
338
315
|
}, [value]);
|
|
339
|
-
return (react_1.default.createElement(exports.BSONValueContainer, { title: stringifiedValue }, stringifiedValue));
|
|
316
|
+
return (react_1.default.createElement(exports.BSONValueContainer, { type: type, title: stringifiedValue }, stringifiedValue));
|
|
340
317
|
};
|
|
341
318
|
const ArrayValue = ({ value, }) => {
|
|
342
319
|
const lengthString = (0, react_1.useMemo)(() => {
|
|
@@ -355,7 +332,8 @@ const ObjectValue = ({ value, }) => {
|
|
|
355
332
|
"Object ",
|
|
356
333
|
lengthString));
|
|
357
334
|
};
|
|
358
|
-
|
|
335
|
+
function BSONValue(genericProps) {
|
|
336
|
+
const props = genericProps;
|
|
359
337
|
switch (props.type) {
|
|
360
338
|
case 'ObjectId':
|
|
361
339
|
return react_1.default.createElement(ObjectIdValue, { value: props.value });
|
|
@@ -376,6 +354,8 @@ const BSONValue = (props) => {
|
|
|
376
354
|
return (react_1.default.createElement(LegacyPythonUUIDValue, { value: props.value }));
|
|
377
355
|
case 'Int32':
|
|
378
356
|
case 'Double':
|
|
357
|
+
case 'Int64':
|
|
358
|
+
case 'Decimal128':
|
|
379
359
|
return react_1.default.createElement(NumberValue, { type: props.type, value: props.value });
|
|
380
360
|
case 'String':
|
|
381
361
|
return react_1.default.createElement(StringValue, { value: props.value });
|
|
@@ -399,5 +379,5 @@ const BSONValue = (props) => {
|
|
|
399
379
|
default:
|
|
400
380
|
return (react_1.default.createElement(UnknownValue, { type: props.type, value: props.value }));
|
|
401
381
|
}
|
|
402
|
-
}
|
|
382
|
+
}
|
|
403
383
|
exports.default = BSONValue;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { GuideCueProvider } from './guide-cue/guide-cue';
|
|
3
3
|
import { SignalHooksProvider } from './signal-popover';
|
|
4
4
|
import { type ContextMenuItem, type ContextMenuItemGroup } from './context-menu';
|
|
5
|
-
import { type
|
|
5
|
+
import { type BSONDisplayOptions } from './document-list/bson-display-options-context';
|
|
6
6
|
type GuideCueProviderProps = React.ComponentProps<typeof GuideCueProvider>;
|
|
7
7
|
type CompassComponentsProviderProps = {
|
|
8
8
|
/**
|
|
@@ -10,7 +10,8 @@ type CompassComponentsProviderProps = {
|
|
|
10
10
|
* value will be derived from the system settings
|
|
11
11
|
*/
|
|
12
12
|
darkMode?: boolean;
|
|
13
|
-
legacyUUIDDisplayEncoding?:
|
|
13
|
+
legacyUUIDDisplayEncoding?: BSONDisplayOptions['legacyUUIDDisplayEncoding'];
|
|
14
|
+
timezone?: BSONDisplayOptions['timezone'];
|
|
14
15
|
popoverPortalContainer?: HTMLElement;
|
|
15
16
|
/**
|
|
16
17
|
* Either React children or a render callback that will get the darkMode
|
|
@@ -25,15 +26,12 @@ type CompassComponentsProviderProps = {
|
|
|
25
26
|
* zIndex for the stacked elements (modal, toast, popover)
|
|
26
27
|
*/
|
|
27
28
|
stackedElementsZIndex?: number;
|
|
28
|
-
/**
|
|
29
|
-
* Set to disable context menus in the application.
|
|
30
|
-
*/
|
|
31
|
-
disableContextMenus?: boolean;
|
|
32
29
|
/**
|
|
33
30
|
* Set to disable guide cues in the application
|
|
34
31
|
*/
|
|
35
32
|
disableGuideCues?: boolean;
|
|
36
33
|
} & {
|
|
34
|
+
onGuideCueShown?: GuideCueProviderProps['onShow'];
|
|
37
35
|
onNextGuideGue?: GuideCueProviderProps['onNext'];
|
|
38
36
|
onNextGuideCueGroup?: GuideCueProviderProps['onNextGroup'];
|
|
39
37
|
} & {
|
|
@@ -50,7 +48,7 @@ type CompassComponentsProviderProps = {
|
|
|
50
48
|
} & {
|
|
51
49
|
onDrawerSectionOpen?: (drawerSectionId: string) => void;
|
|
52
50
|
onDrawerSectionHide?: (drawerSectionId: string) => void;
|
|
53
|
-
} & React.ComponentProps<typeof SignalHooksProvider>;
|
|
51
|
+
} & Omit<React.ComponentProps<typeof SignalHooksProvider>, 'children'>;
|
|
54
52
|
/**
|
|
55
53
|
* This component combines most of the existing compass-component providers into
|
|
56
54
|
* one for the purposes of being reused between compass-main (electron) and
|
|
@@ -63,6 +61,6 @@ type CompassComponentsProviderProps = {
|
|
|
63
61
|
* whether or not it can be used completely interchangeably between electron and
|
|
64
62
|
* browser environment.
|
|
65
63
|
*/
|
|
66
|
-
export declare const CompassComponentsProvider: ({ darkMode: _darkMode, children, legacyUUIDDisplayEncoding, onNextGuideGue, onNextGuideCueGroup, onContextMenuOpen, onContextMenuItemClick, onDrawerSectionOpen, onDrawerSectionHide, utmSource, utmMedium, stackedElementsZIndex, popoverPortalContainer: _popoverPortalContainer,
|
|
64
|
+
export declare const CompassComponentsProvider: ({ darkMode: _darkMode, children, legacyUUIDDisplayEncoding, timezone, onGuideCueShown, onNextGuideGue, onNextGuideCueGroup, onContextMenuOpen, onContextMenuItemClick, onDrawerSectionOpen, onDrawerSectionHide, utmSource, utmMedium, stackedElementsZIndex, popoverPortalContainer: _popoverPortalContainer, disableGuideCues, ...signalHooksProviderProps }: CompassComponentsProviderProps) => React.JSX.Element;
|
|
67
65
|
export {};
|
|
68
66
|
//# sourceMappingURL=compass-components-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compass-components-provider.d.ts","sourceRoot":"","sources":["../../src/components/compass-components-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAI5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAE1B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"compass-components-provider.d.ts","sourceRoot":"","sources":["../../src/components/compass-components-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAI5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAE1B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,8CAA8C,CAAC;AAEtD,KAAK,qBAAqB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE3E,KAAK,8BAA8B,GAAG;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yBAAyB,CAAC,EAAE,kBAAkB,CAAC,2BAA2B,CAAC,CAAC;IAC5E,QAAQ,CAAC,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC1C,sBAAsB,CAAC,EAAE,WAAW,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,EACL,KAAK,CAAC,SAAS,GACf,CAAC,CAAC,EACA,QAAQ,GACT,EAAE;QACD,QAAQ,EAAE,OAAO,CAAC;QAClB,kBAAkB,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC3C,kBAAkB,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;KAC5C,KAAK,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACrC;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,GAAG;IACF,eAAe,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAClD,cAAc,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACjD,mBAAmB,CAAC,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;CAC5D,GAAG;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,oBAAoB,EAAE,KAAK,IAAI,CAAC;IACjE;;OAEG;IACH,sBAAsB,CAAC,EAAE,CACvB,SAAS,EAAE,oBAAoB,EAC/B,IAAI,EAAE,eAAe,KAClB,IAAI,CAAC;CACX,GAAG;IACF,mBAAmB,CAAC,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,mBAAmB,CAAC,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,IAAI,CAAC;CACzD,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,mBAAmB,CAAC,EAAE,UAAU,CAAC,CAAC;AAuCvE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,GAAI,gWAkBvC,8BAA8B,sBAsEhC,CAAC"}
|
|
@@ -48,7 +48,7 @@ const use_stacked_component_1 = require("../hooks/use-stacked-component");
|
|
|
48
48
|
const context_menu_1 = require("./context-menu");
|
|
49
49
|
const drawer_portal_1 = require("./drawer-portal");
|
|
50
50
|
const use_copy_paste_context_menu_1 = require("../hooks/use-copy-paste-context-menu");
|
|
51
|
-
const
|
|
51
|
+
const bson_display_options_context_1 = require("./document-list/bson-display-options-context");
|
|
52
52
|
const darkModeMediaQuery = (() => {
|
|
53
53
|
return typeof window !== 'undefined' && window.matchMedia
|
|
54
54
|
? window.matchMedia('(prefers-color-scheme: dark)')
|
|
@@ -91,7 +91,7 @@ function useDarkMode(_darkMode) {
|
|
|
91
91
|
* whether or not it can be used completely interchangeably between electron and
|
|
92
92
|
* browser environment.
|
|
93
93
|
*/
|
|
94
|
-
const CompassComponentsProvider = ({ darkMode: _darkMode, children, legacyUUIDDisplayEncoding, onNextGuideGue, onNextGuideCueGroup, onContextMenuOpen, onContextMenuItemClick, onDrawerSectionOpen, onDrawerSectionHide, utmSource, utmMedium, stackedElementsZIndex, popoverPortalContainer: _popoverPortalContainer,
|
|
94
|
+
const CompassComponentsProvider = ({ darkMode: _darkMode, children, legacyUUIDDisplayEncoding, timezone, onGuideCueShown, onNextGuideGue, onNextGuideCueGroup, onContextMenuOpen, onContextMenuItemClick, onDrawerSectionOpen, onDrawerSectionHide, utmSource, utmMedium, stackedElementsZIndex, popoverPortalContainer: _popoverPortalContainer, disableGuideCues, ...signalHooksProviderProps }) => {
|
|
95
95
|
const darkMode = useDarkMode(_darkMode);
|
|
96
96
|
// Leafygreen doesn't accept refs for dom elements so we are required to
|
|
97
97
|
// trigger a state update when the popover ref is resolved. This is very
|
|
@@ -104,14 +104,14 @@ const CompassComponentsProvider = ({ darkMode: _darkMode, children, legacyUUIDDi
|
|
|
104
104
|
return { portalContainer, scrollContainer };
|
|
105
105
|
}, [portalContainer, scrollContainer]);
|
|
106
106
|
return (react_1.default.createElement(leafygreen_provider_1.default, { darkMode: darkMode, popoverPortalContainer: popoverPortalContainer },
|
|
107
|
-
react_1.default.createElement(
|
|
107
|
+
react_1.default.createElement(bson_display_options_context_1.BSONDisplayOptionsProvider, { legacyUUIDDisplayEncoding: legacyUUIDDisplayEncoding, timezone: timezone },
|
|
108
108
|
react_1.default.createElement(drawer_portal_1.DrawerContentProvider, { onDrawerSectionOpen: onDrawerSectionOpen, onDrawerSectionHide: onDrawerSectionHide },
|
|
109
109
|
react_1.default.createElement(use_stacked_component_1.StackedComponentProvider, { zIndex: stackedElementsZIndex },
|
|
110
110
|
react_1.default.createElement(link_1.RequiredURLSearchParamsProvider, { utmSource: utmSource, utmMedium: utmMedium },
|
|
111
|
-
react_1.default.createElement(guide_cue_1.GuideCueProvider, { onNext: onNextGuideGue, onNextGroup: onNextGuideCueGroup, disabled: disableGuideCues },
|
|
111
|
+
react_1.default.createElement(guide_cue_1.GuideCueProvider, { onShow: onGuideCueShown, onNext: onNextGuideGue, onNextGroup: onNextGuideCueGroup, disabled: disableGuideCues },
|
|
112
112
|
react_1.default.createElement(signal_popover_1.SignalHooksProvider, { ...signalHooksProviderProps },
|
|
113
113
|
react_1.default.createElement(use_confirmation_1.ConfirmationModalArea, null,
|
|
114
|
-
react_1.default.createElement(context_menu_1.ContextMenuProvider, {
|
|
114
|
+
react_1.default.createElement(context_menu_1.ContextMenuProvider, { onContextMenuOpen: onContextMenuOpen, onContextMenuItemClick: onContextMenuItemClick },
|
|
115
115
|
react_1.default.createElement(use_copy_paste_context_menu_1.CopyPasteContextMenu, null,
|
|
116
116
|
react_1.default.createElement(use_toast_1.ToastArea, null, typeof children === 'function'
|
|
117
117
|
? children({
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type ContextMenuItem, type ContextMenuItemGroup, type ContextMenuWrapperProps } from '@mongodb-js/compass-context-menu';
|
|
3
3
|
export type { ContextMenuItem, ContextMenuItemGroup, } from '@mongodb-js/compass-context-menu';
|
|
4
|
-
export declare function ContextMenuProvider({ children,
|
|
4
|
+
export declare function ContextMenuProvider({ children, onContextMenuItemClick, onContextMenuOpen, }: {
|
|
5
5
|
children: React.ReactNode;
|
|
6
|
-
disabled?: boolean;
|
|
7
6
|
onContextMenuOpen?: (itemGroups: ContextMenuItemGroup[]) => void;
|
|
8
7
|
onContextMenuItemClick?: (itemGroup: ContextMenuItemGroup, item: ContextMenuItem) => void;
|
|
9
8
|
}): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-menu.d.ts","sourceRoot":"","sources":["../../src/components/context-menu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAKhE,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAE7B,MAAM,kCAAkC,CAAC;AAG1C,YAAY,EACV,eAAe,EACf,oBAAoB,GACrB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"context-menu.d.ts","sourceRoot":"","sources":["../../src/components/context-menu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAKhE,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAE7B,MAAM,kCAAkC,CAAC;AAG1C,YAAY,EACV,eAAe,EACf,oBAAoB,GACrB,MAAM,kCAAkC,CAAC;AAkB1C,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,sBAAsB,EACtB,iBAAiB,GAClB,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,oBAAoB,EAAE,KAAK,IAAI,CAAC;IACjE,sBAAsB,CAAC,EAAE,CACvB,SAAS,EAAE,oBAAoB,EAC/B,IAAI,EAAE,eAAe,KAClB,IAAI,CAAC;CACX,qBAcA;AAED,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,sBAAsB,GACvB,EAAE,uBAAuB,GAAG;IAC3B,sBAAsB,CAAC,EAAE,CACvB,SAAS,EAAE,oBAAoB,EAC/B,IAAI,EAAE,eAAe,KAClB,IAAI,CAAC;CACX,qBAoFA;AAED,+FAA+F;AAC/F,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,CACb,CAAC,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAAG;IACrC,KAAK,EAAE,SAAS,GAAG,CAAC,eAAe,GAAG,SAAS,CAAC,EAAE,CAAC;CACpD,CAAC,GACF,SAAS,CACZ,EAAE,EACH,YAAY,GAAE,KAAK,CAAC,cAAmB,GACtC,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CA2BhC"}
|
|
@@ -46,14 +46,17 @@ const use_current_value_ref_1 = require("../hooks/use-current-value-ref");
|
|
|
46
46
|
const menuStyles = (0, emotion_1.css)({
|
|
47
47
|
paddingTop: tokens_1.spacing[150],
|
|
48
48
|
paddingBottom: tokens_1.spacing[150],
|
|
49
|
+
width: 'max-content',
|
|
50
|
+
// LG default width for menu
|
|
51
|
+
minWidth: 210,
|
|
49
52
|
});
|
|
50
53
|
const itemStyles = (0, emotion_1.css)({
|
|
51
54
|
paddingTop: 0,
|
|
52
55
|
paddingBottom: 0,
|
|
53
56
|
fontSize: '.8em',
|
|
54
57
|
});
|
|
55
|
-
function ContextMenuProvider({ children,
|
|
56
|
-
return (react_1.default.createElement(compass_context_menu_1.ContextMenuProvider, {
|
|
58
|
+
function ContextMenuProvider({ children, onContextMenuItemClick, onContextMenuOpen, }) {
|
|
59
|
+
return (react_1.default.createElement(compass_context_menu_1.ContextMenuProvider, { menuWrapper: (props) => (react_1.default.createElement(ContextMenu, { ...props, onContextMenuItemClick: onContextMenuItemClick })), onContextMenuOpen: onContextMenuOpen }, children));
|
|
57
60
|
}
|
|
58
61
|
function ContextMenu({ menu, onContextMenuItemClick, }) {
|
|
59
62
|
const menuRef = (0, react_1.useRef)(null);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type LegacyUUIDDisplay = '' | 'LegacyJavaUUID' | 'LegacyCSharpUUID' | 'LegacyPythonUUID';
|
|
3
|
+
export type BSONDisplayOptions = {
|
|
4
|
+
legacyUUIDDisplayEncoding: LegacyUUIDDisplay;
|
|
5
|
+
timezone: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const DEFAULT_BSON_DISPLAY_OPTIONS: BSONDisplayOptions;
|
|
8
|
+
export declare const BSONDisplayOptionsContext: React.Context<BSONDisplayOptions>;
|
|
9
|
+
export declare function useBSONDisplayOptions(): BSONDisplayOptions;
|
|
10
|
+
export declare const BSONDisplayOptionsProvider: React.FunctionComponent<Partial<BSONDisplayOptions> & {
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=bson-display-options-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bson-display-options-context.d.ts","sourceRoot":"","sources":["../../../src/components/document-list/bson-display-options-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAElE,MAAM,MAAM,iBAAiB,GACzB,EAAE,GACF,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,CAAC;AAEvB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,yBAAyB,EAAE,iBAAiB,CAAC;IAC7C,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,kBAG1C,CAAC;AAEF,eAAO,MAAM,yBAAyB,mCAErC,CAAC;AAEF,wBAAgB,qBAAqB,IAAI,kBAAkB,CAE1D;AAED,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,iBAAiB,CAC9D,OAAO,CAAC,kBAAkB,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAkB7D,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.BSONDisplayOptionsProvider = exports.BSONDisplayOptionsContext = exports.DEFAULT_BSON_DISPLAY_OPTIONS = void 0;
|
|
37
|
+
exports.useBSONDisplayOptions = useBSONDisplayOptions;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
exports.DEFAULT_BSON_DISPLAY_OPTIONS = {
|
|
40
|
+
legacyUUIDDisplayEncoding: '',
|
|
41
|
+
timezone: 'UTC',
|
|
42
|
+
};
|
|
43
|
+
exports.BSONDisplayOptionsContext = (0, react_1.createContext)(exports.DEFAULT_BSON_DISPLAY_OPTIONS);
|
|
44
|
+
function useBSONDisplayOptions() {
|
|
45
|
+
return (0, react_1.useContext)(exports.BSONDisplayOptionsContext);
|
|
46
|
+
}
|
|
47
|
+
const BSONDisplayOptionsProvider = ({ legacyUUIDDisplayEncoding = exports.DEFAULT_BSON_DISPLAY_OPTIONS.legacyUUIDDisplayEncoding, timezone = exports.DEFAULT_BSON_DISPLAY_OPTIONS.timezone, children, }) => {
|
|
48
|
+
const value = (0, react_1.useMemo)(() => {
|
|
49
|
+
return {
|
|
50
|
+
legacyUUIDDisplayEncoding,
|
|
51
|
+
timezone,
|
|
52
|
+
};
|
|
53
|
+
}, [legacyUUIDDisplayEncoding, timezone]);
|
|
54
|
+
return (react_1.default.createElement(exports.BSONDisplayOptionsContext.Provider, { value: value }, children));
|
|
55
|
+
};
|
|
56
|
+
exports.BSONDisplayOptionsProvider = BSONDisplayOptionsProvider;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TypeCastMap } from 'hadron-type-checker';
|
|
2
|
+
type BSONValueType = keyof TypeCastMap | 'DBRef';
|
|
3
|
+
export declare const bsonValueDisplayVar = "--bson-value-display";
|
|
4
|
+
export declare const BSON_TYPE_LABEL: Partial<Record<keyof TypeCastMap, string>>;
|
|
5
|
+
export declare function wrapValueWithBsonLabel(type: keyof TypeCastMap, value: string): string;
|
|
6
|
+
export declare function useBsonThemeStyles(type?: BSONValueType): {
|
|
7
|
+
color: string | undefined;
|
|
8
|
+
} | undefined;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=bson-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bson-utils.d.ts","sourceRoot":"","sources":["../../../src/components/document-list/bson-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOvD,KAAK,aAAa,GAAG,MAAM,WAAW,GAAG,OAAO,CAAC;AAGjD,eAAO,MAAM,mBAAmB,yBAAyB,CAAC;AA+B1D,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,WAAW,EAAE,MAAM,CAAC,CAS7D,CAAC;AAEX,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,WAAW,EACvB,KAAK,EAAE,MAAM,GACZ,MAAM,CAMR;AAED,wBAAgB,kBAAkB,CAAC,IAAI,CAAC,EAAE,aAAa;;cAatD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BSON_TYPE_LABEL = exports.bsonValueDisplayVar = void 0;
|
|
4
|
+
exports.wrapValueWithBsonLabel = wrapValueWithBsonLabel;
|
|
5
|
+
exports.useBsonThemeStyles = useBsonThemeStyles;
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const code_1 = require("@leafygreen-ui/code");
|
|
8
|
+
const use_theme_1 = require("../../hooks/use-theme");
|
|
9
|
+
// Set by containers laying values out inline, see `elementContentInline`.
|
|
10
|
+
exports.bsonValueDisplayVar = '--bson-value-display';
|
|
11
|
+
// Colors used to render bson values both in the read-only and the editing
|
|
12
|
+
// state of a document.
|
|
13
|
+
const VALUE_COLOR_BY_THEME_AND_TYPE = {
|
|
14
|
+
[use_theme_1.Themes.Dark]: {
|
|
15
|
+
Int32: code_1.variantColors.dark[9],
|
|
16
|
+
Int64: code_1.variantColors.dark[9],
|
|
17
|
+
Double: code_1.variantColors.dark[9],
|
|
18
|
+
Decimal128: code_1.variantColors.dark[9],
|
|
19
|
+
Date: code_1.variantColors.dark[9],
|
|
20
|
+
Boolean: code_1.variantColors.dark[10],
|
|
21
|
+
String: code_1.variantColors.dark[7],
|
|
22
|
+
ObjectId: code_1.variantColors.dark[5],
|
|
23
|
+
},
|
|
24
|
+
[use_theme_1.Themes.Light]: {
|
|
25
|
+
Int32: code_1.variantColors.light[9],
|
|
26
|
+
Int64: code_1.variantColors.light[9],
|
|
27
|
+
Double: code_1.variantColors.light[9],
|
|
28
|
+
Decimal128: code_1.variantColors.light[9],
|
|
29
|
+
Date: code_1.variantColors.light[9],
|
|
30
|
+
Boolean: code_1.variantColors.light[10],
|
|
31
|
+
String: code_1.variantColors.light[7],
|
|
32
|
+
ObjectId: code_1.variantColors.light[5],
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
// This is the list of bson types to map to their corresponding label on the UI.
|
|
36
|
+
exports.BSON_TYPE_LABEL = {
|
|
37
|
+
Int64: 'Long',
|
|
38
|
+
Decimal128: 'Decimal128',
|
|
39
|
+
ObjectId: 'ObjectId',
|
|
40
|
+
Date: 'ISODate',
|
|
41
|
+
UUID: 'UUID',
|
|
42
|
+
LegacyJavaUUID: 'LegacyJavaUUID',
|
|
43
|
+
LegacyCSharpUUID: 'LegacyCSharpUUID',
|
|
44
|
+
LegacyPythonUUID: 'LegacyPythonUUID',
|
|
45
|
+
};
|
|
46
|
+
function wrapValueWithBsonLabel(type, value) {
|
|
47
|
+
const label = exports.BSON_TYPE_LABEL[type];
|
|
48
|
+
if (!label) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
return `${label}('${value}')`;
|
|
52
|
+
}
|
|
53
|
+
function useBsonThemeStyles(type) {
|
|
54
|
+
const darkMode = (0, use_theme_1.useDarkMode)();
|
|
55
|
+
return (0, react_1.useMemo)(() => {
|
|
56
|
+
if (!type) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
color: VALUE_COLOR_BY_THEME_AND_TYPE[darkMode ? use_theme_1.Themes.Dark : use_theme_1.Themes.Light][type],
|
|
61
|
+
};
|
|
62
|
+
}, [type, darkMode]);
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-time-picker.d.ts","sourceRoot":"","sources":["../../../src/components/document-list/date-time-picker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AA8C7D,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,qBAiEA"}
|