@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
|
@@ -0,0 +1,85 @@
|
|
|
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.TextEditor = TextEditor;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
39
|
+
const bson_value_1 = require("../../bson-value");
|
|
40
|
+
const typography_1 = require("../typography");
|
|
41
|
+
const shared_1 = require("./shared");
|
|
42
|
+
const textareaContainer = (0, emotion_1.css)({
|
|
43
|
+
width: '100%',
|
|
44
|
+
maxWidth: '100%',
|
|
45
|
+
'&::before, &::after': {
|
|
46
|
+
content: "'\"'",
|
|
47
|
+
userSelect: 'none',
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const editorTextarea = (0, emotion_1.css)({
|
|
51
|
+
display: 'inline-block',
|
|
52
|
+
whiteSpace: 'nowrap',
|
|
53
|
+
minWidth: '5ch',
|
|
54
|
+
// 2ch for `"` around the textarea
|
|
55
|
+
maxWidth: 'calc(100% - 2ch)',
|
|
56
|
+
verticalAlign: 'top',
|
|
57
|
+
color: 'inherit',
|
|
58
|
+
});
|
|
59
|
+
function TextEditor({ value: val, valid, onChange, autoFocus, onBlur, ...props }) {
|
|
60
|
+
const inputStyle = (0, react_1.useMemo)(() => {
|
|
61
|
+
const lines = val.split('\n');
|
|
62
|
+
let longestLineCharLength = 0;
|
|
63
|
+
for (const line of lines) {
|
|
64
|
+
const length = line.length;
|
|
65
|
+
if (length > longestLineCharLength) {
|
|
66
|
+
longestLineCharLength = length;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const width = `${Math.min(
|
|
70
|
+
// Adding one to account for a textarea resize icon button thingie
|
|
71
|
+
longestLineCharLength + 1, 70)}ch`;
|
|
72
|
+
const minLines = Math.max(lines.length, longestLineCharLength > 70 ? 2 : 1);
|
|
73
|
+
const maxLines = Math.min(minLines, 10);
|
|
74
|
+
const minHeight = typography_1.documentTypography.lineHeight * Math.min(minLines, maxLines);
|
|
75
|
+
const height = typography_1.documentTypography.lineHeight * maxLines;
|
|
76
|
+
return { width, minHeight, height };
|
|
77
|
+
}, [val]);
|
|
78
|
+
return (react_1.default.createElement(bson_value_1.BSONValueContainer, { type: "String", className: (0, emotion_1.cx)(textareaContainer) },
|
|
79
|
+
react_1.default.createElement("textarea", { "data-testid": "hadron-document-value-editor", value: val, onChange: (evt) => {
|
|
80
|
+
onChange(evt.currentTarget.value);
|
|
81
|
+
}, onBlur: onBlur,
|
|
82
|
+
// See ../element.tsx
|
|
83
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
84
|
+
autoFocus: autoFocus, className: (0, emotion_1.cx)(shared_1.editorStyles, editorTextarea, !valid && shared_1.editorInvalidStyles), spellCheck: "false", style: inputStyle, ...props })));
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid-editor.d.ts","sourceRoot":"","sources":["../../../../src/components/document-list/editors/uuid-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAW5C,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,qBAiBhE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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.UUIDEditor = UUIDEditor;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
39
|
+
const editor_with_label_1 = require("./editor-with-label");
|
|
40
|
+
const input_editor_1 = require("./input-editor");
|
|
41
|
+
const uuidEditorInput = (0, emotion_1.css)({
|
|
42
|
+
display: 'inline-block',
|
|
43
|
+
whiteSpace: 'nowrap',
|
|
44
|
+
verticalAlign: 'top',
|
|
45
|
+
color: 'inherit',
|
|
46
|
+
});
|
|
47
|
+
function UUIDEditor({ value, type, ...props }) {
|
|
48
|
+
const inputStyle = (0, react_1.useMemo)(() => {
|
|
49
|
+
// UUID format is 36 characters (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
|
|
50
|
+
return { width: `${Math.max(value.length, 36)}ch` };
|
|
51
|
+
}, [value]);
|
|
52
|
+
return (react_1.default.createElement(editor_with_label_1.EditorWithLabel, { type: type },
|
|
53
|
+
react_1.default.createElement(input_editor_1.InputEditor, { value: value, placeholder: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", ...props, className: uuidEditorInput, style: inputStyle })));
|
|
54
|
+
}
|
|
@@ -13,7 +13,7 @@ export declare const KeyEditor: React.FunctionComponent<{
|
|
|
13
13
|
export declare const ValueEditor: React.FunctionComponent<{
|
|
14
14
|
editing?: boolean;
|
|
15
15
|
onEditStart(): void;
|
|
16
|
-
type:
|
|
16
|
+
type: keyof TypeCastMap;
|
|
17
17
|
value: string;
|
|
18
18
|
valid: boolean;
|
|
19
19
|
validationMessage: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-editors.d.ts","sourceRoot":"","sources":["../../../src/components/document-list/element-editors.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"element-editors.d.ts","sourceRoot":"","sources":["../../../src/components/document-list/element-editors.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AA8CvD,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,IAAI,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CA6EA,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,IAAI,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,WAAW,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,aAAa,EAAE,WAAW,CAAC,MAAM,WAAW,CAAC,CAAC;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,IAAI,IAAI,CAAC;IAChB,MAAM,IAAI,IAAI,CAAC;CAChB,CA0EA,CAAC;AA8CF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAClD,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAkDA,CAAC"}
|
|
@@ -32,58 +32,50 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
exports.TypeEditor = exports.ValueEditor = exports.KeyEditor = void 0;
|
|
37
|
-
const react_1 =
|
|
40
|
+
const react_1 = __importDefault(require("react"));
|
|
38
41
|
const hadron_type_checker_1 = __importStar(require("hadron-type-checker"));
|
|
39
42
|
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
40
43
|
const palette_1 = require("@leafygreen-ui/palette");
|
|
41
44
|
const tokens_1 = require("@leafygreen-ui/tokens");
|
|
42
|
-
const bson_value_1 =
|
|
45
|
+
const bson_value_1 = __importDefault(require("../bson-value"));
|
|
43
46
|
const merge_props_1 = require("../../utils/merge-props");
|
|
44
|
-
const typography_1 = require("./typography");
|
|
45
47
|
const leafygreen_1 = require("../leafygreen");
|
|
46
48
|
const use_theme_1 = require("../../hooks/use-theme");
|
|
49
|
+
const shared_1 = require("./editors/shared");
|
|
50
|
+
const date_editor_1 = require("./editors/date-editor");
|
|
51
|
+
const default_editor_1 = require("./editors/default-editor");
|
|
52
|
+
const text_editor_1 = require("./editors/text-editor");
|
|
53
|
+
const uuid_editor_1 = require("./editors/uuid-editor");
|
|
47
54
|
const maxWidth = (0, emotion_1.css)({
|
|
48
55
|
maxWidth: '100%',
|
|
49
56
|
overflowX: 'hidden',
|
|
50
57
|
textOverflow: 'ellipsis',
|
|
51
58
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
boxShadow: 'none',
|
|
57
|
-
outline: 'none',
|
|
58
|
-
backgroundColor: 'transparent',
|
|
59
|
+
// Sizes the input to its content by overlaying it on a hidden copy of the text,
|
|
60
|
+
// so that the key occupies the same width when viewing and when editing.
|
|
61
|
+
const keyEditorSizer = (0, emotion_1.css)({
|
|
62
|
+
display: 'inline-grid',
|
|
59
63
|
maxWidth: '100%',
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
verticalAlign: 'bottom',
|
|
65
|
+
'&::after': {
|
|
66
|
+
content: 'attr(data-value)',
|
|
67
|
+
visibility: 'hidden',
|
|
68
|
+
whiteSpace: 'pre',
|
|
65
69
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
'&::after, & > input': {
|
|
71
|
+
gridArea: '1 / 1',
|
|
72
|
+
font: 'inherit',
|
|
73
|
+
width: '100%',
|
|
74
|
+
minWidth: 0,
|
|
70
75
|
},
|
|
71
76
|
});
|
|
72
|
-
const editorInvalidLightMode = (0, emotion_1.css)({
|
|
73
|
-
backgroundColor: palette_1.palette.red.light2,
|
|
74
|
-
color: palette_1.palette.red.dark2,
|
|
75
|
-
});
|
|
76
|
-
const editorInvalidDarkMode = (0, emotion_1.css)({
|
|
77
|
-
backgroundColor: palette_1.palette.red.dark2,
|
|
78
|
-
color: palette_1.palette.red.light2,
|
|
79
|
-
});
|
|
80
77
|
const KeyEditor = ({ editing, value, valid, validationMessage, onChange, autoFocus, onEditStart, }) => {
|
|
81
78
|
const darkMode = (0, use_theme_1.useDarkMode)();
|
|
82
|
-
// On Safari if a text is 5 mono-characters wide and is supposed to overflow /
|
|
83
|
-
// get ellipse'd only when shorter than that, it would still overflow and get
|
|
84
|
-
// ellipse'd under normal conditions, for unknown reasons. For that, we add a
|
|
85
|
-
// small amount to the width to tackle this issue.
|
|
86
|
-
const width = `${Math.max(value.length, 1)}.5ch`;
|
|
87
79
|
return (react_1.default.createElement(react_1.default.Fragment, null, editing ? (react_1.default.createElement(leafygreen_1.Tooltip, { darkMode: true, enabled: !valid, trigger: ({ className, children,
|
|
88
80
|
// Having a tooltip connected to the input elements is not the most
|
|
89
81
|
// accessible thing ever and so a lot of event listeners of the
|
|
@@ -93,119 +85,48 @@ const KeyEditor = ({ editing, value, valid, validationMessage, onChange, autoFoc
|
|
|
93
85
|
// for our case
|
|
94
86
|
onDragStart, onPointerUp, onPointerDown, onMouseDown, ...triggerProps }) => {
|
|
95
87
|
return (react_1.default.createElement("div", { className: className },
|
|
96
|
-
react_1.default.createElement("
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
(
|
|
103
|
-
|
|
104
|
-
|
|
88
|
+
react_1.default.createElement("span", { className: keyEditorSizer, "data-value": value },
|
|
89
|
+
react_1.default.createElement("input", { type: "text", size: 1, "data-testid": "hadron-document-key-editor", value: value, onChange: (evt) => {
|
|
90
|
+
onChange(evt.currentTarget.value);
|
|
91
|
+
},
|
|
92
|
+
// See ./element.tsx
|
|
93
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
94
|
+
autoFocus: autoFocus, className: (0, emotion_1.cx)(maxWidth, shared_1.editorStyles, !valid && shared_1.editorInvalidStyles, !valid &&
|
|
95
|
+
(darkMode
|
|
96
|
+
? shared_1.editorInvalidDarkModeStyles
|
|
97
|
+
: shared_1.editorInvalidLightModeStyles)), spellCheck: "false", ...triggerProps })),
|
|
105
98
|
children));
|
|
106
|
-
} }, validationMessage)) : (react_1.default.createElement("
|
|
99
|
+
} }, validationMessage)) : (react_1.default.createElement("span", { "data-testid": "hadron-document-clickable-key", onDoubleClick: onEditStart }, value))));
|
|
107
100
|
};
|
|
108
101
|
exports.KeyEditor = KeyEditor;
|
|
109
|
-
const textareaContainer = (0, emotion_1.css)({
|
|
110
|
-
width: '100%',
|
|
111
|
-
maxWidth: '100%',
|
|
112
|
-
'&::before, &::after': {
|
|
113
|
-
content: "'\"'",
|
|
114
|
-
userSelect: 'none',
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
const editorTextarea = (0, emotion_1.css)({
|
|
118
|
-
display: 'inline-block',
|
|
119
|
-
whiteSpace: 'nowrap',
|
|
120
|
-
minWidth: '5ch',
|
|
121
|
-
// 2ch for `"` around the textarea
|
|
122
|
-
maxWidth: 'calc(100% - 2ch)',
|
|
123
|
-
verticalAlign: 'top',
|
|
124
|
-
color: 'inherit',
|
|
125
|
-
});
|
|
126
|
-
// UUID editor container that shows: UUID(" <input> ")
|
|
127
|
-
const uuidEditorContainer = (0, emotion_1.css)({
|
|
128
|
-
display: 'inline-flex',
|
|
129
|
-
alignItems: 'center',
|
|
130
|
-
maxWidth: '100%',
|
|
131
|
-
});
|
|
132
|
-
const uuidEditorInput = (0, emotion_1.css)({
|
|
133
|
-
display: 'inline-block',
|
|
134
|
-
whiteSpace: 'nowrap',
|
|
135
|
-
verticalAlign: 'top',
|
|
136
|
-
color: 'inherit',
|
|
137
|
-
});
|
|
138
|
-
const uuidEditorLabel = (0, emotion_1.css)({
|
|
139
|
-
userSelect: 'none',
|
|
140
|
-
whiteSpace: 'nowrap',
|
|
141
|
-
});
|
|
142
102
|
const ValueEditor = ({ editing, onEditStart, type, value, valid, validationMessage, originalValue, autoFocus, onChange, onFocus, onBlur, }) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
longestLineCharLength + 1, 70)}ch`;
|
|
158
|
-
const minLines = Math.max(lines.length, longestLineCharLength > 70 ? 2 : 1);
|
|
159
|
-
const maxLines = Math.min(minLines, 10);
|
|
160
|
-
const minHeight = typography_1.documentTypography.lineHeight * Math.min(minLines, maxLines);
|
|
161
|
-
const height = typography_1.documentTypography.lineHeight * maxLines;
|
|
162
|
-
return { width, minHeight, height };
|
|
163
|
-
}
|
|
164
|
-
return { width: `${Math.max(val.length, 1)}ch` };
|
|
165
|
-
}, [val, type]);
|
|
166
|
-
const uuidInputStyle = (0, react_1.useMemo)(() => {
|
|
167
|
-
// UUID format is 36 characters (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
|
|
168
|
-
return { width: `${Math.max(val.length, 36)}ch` };
|
|
169
|
-
}, [val]);
|
|
170
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, editing ? (react_1.default.createElement(leafygreen_1.Tooltip, { darkMode: true, enabled: !valid, trigger: ({ className, children,
|
|
103
|
+
if (!editing) {
|
|
104
|
+
// Double-click is not accessible so no reason for this to be a button,
|
|
105
|
+
// users won't be able to interact with it anyway
|
|
106
|
+
return (react_1.default.createElement("span", { "data-testid": "hadron-document-clickable-value", onDoubleClick: onEditStart },
|
|
107
|
+
react_1.default.createElement(bson_value_1.default, { type: type, value: originalValue })));
|
|
108
|
+
}
|
|
109
|
+
const sharedProps = {
|
|
110
|
+
autoFocus,
|
|
111
|
+
value: String(value),
|
|
112
|
+
valid,
|
|
113
|
+
onChange,
|
|
114
|
+
onBlur,
|
|
115
|
+
};
|
|
116
|
+
return (react_1.default.createElement(leafygreen_1.Tooltip, { darkMode: true, enabled: !valid, trigger: ({ className, children,
|
|
171
117
|
// See above
|
|
172
118
|
onDragStart, onPointerUp, onPointerDown, onMouseDown, ...triggerProps }) => {
|
|
173
119
|
// NB: Order is important, if triggerProps has onFocus / onBlur we
|
|
174
120
|
// want to merge them with ours, if they are not passed, we want our
|
|
175
121
|
// listeners to overwrite undefined keys
|
|
176
|
-
const mergedProps = (0, merge_props_1.mergeProps)(triggerProps, {
|
|
122
|
+
const mergedProps = (0, merge_props_1.mergeProps)(triggerProps, {
|
|
123
|
+
onBlur,
|
|
124
|
+
onFocus,
|
|
125
|
+
});
|
|
177
126
|
return (react_1.default.createElement("div", { className: className },
|
|
178
|
-
type === 'String' ? (react_1.default.createElement(
|
|
179
|
-
react_1.default.createElement("textarea", { "data-testid": "hadron-document-value-editor", value: val, onChange: (evt) => {
|
|
180
|
-
onChange(evt.currentTarget.value);
|
|
181
|
-
},
|
|
182
|
-
// See ./element.tsx
|
|
183
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
184
|
-
autoFocus: autoFocus, className: (0, emotion_1.cx)(editorReset, editorOutline, editorTextarea, !valid && editorInvalid), spellCheck: "false", style: inputStyle, ...mergedProps }))) : (0, hadron_type_checker_1.isUUIDType)(type) ? (react_1.default.createElement("div", { className: uuidEditorContainer },
|
|
185
|
-
react_1.default.createElement("span", { className: uuidEditorLabel },
|
|
186
|
-
type,
|
|
187
|
-
"('"),
|
|
188
|
-
react_1.default.createElement("input", { type: "text", "data-testid": "hadron-document-value-editor", value: val, placeholder: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", onChange: (evt) => {
|
|
189
|
-
onChange(evt.currentTarget.value);
|
|
190
|
-
},
|
|
191
|
-
// See ./element.tsx
|
|
192
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
193
|
-
autoFocus: autoFocus, className: (0, emotion_1.cx)(editorReset, editorOutline, uuidEditorInput, !valid && editorInvalid, !valid &&
|
|
194
|
-
(darkMode
|
|
195
|
-
? editorInvalidDarkMode
|
|
196
|
-
: editorInvalidLightMode)), spellCheck: "false", style: uuidInputStyle, ...mergedProps }),
|
|
197
|
-
react_1.default.createElement("span", { className: uuidEditorLabel }, "')"))) : (react_1.default.createElement("input", { type: "text", "data-testid": "hadron-document-value-editor", value: val, onChange: (evt) => {
|
|
198
|
-
onChange(evt.currentTarget.value);
|
|
199
|
-
},
|
|
200
|
-
// See ./element.tsx
|
|
201
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
202
|
-
autoFocus: autoFocus, className: (0, emotion_1.cx)(editorReset, editorOutline, !valid && editorInvalid, !valid &&
|
|
203
|
-
(darkMode
|
|
204
|
-
? editorInvalidDarkMode
|
|
205
|
-
: editorInvalidLightMode)), style: inputStyle, spellCheck: "false", ...mergedProps })),
|
|
127
|
+
type === 'String' ? (react_1.default.createElement(text_editor_1.TextEditor, { ...mergedProps, ...sharedProps })) : type === 'Date' ? (react_1.default.createElement(date_editor_1.DateEditor, { ...sharedProps, ...mergedProps, type: type })) : (0, hadron_type_checker_1.isUUIDType)(type) ? (react_1.default.createElement(uuid_editor_1.UUIDEditor, { ...sharedProps, ...mergedProps, type: type })) : (react_1.default.createElement(default_editor_1.DefaultEditor, { ...sharedProps, ...mergedProps, type: type })),
|
|
206
128
|
children));
|
|
207
|
-
} }, validationMessage))
|
|
208
|
-
react_1.default.createElement(bson_value_1.default, { type: type, value: originalValue })))));
|
|
129
|
+
} }, validationMessage));
|
|
209
130
|
};
|
|
210
131
|
exports.ValueEditor = ValueEditor;
|
|
211
132
|
const TYPES = hadron_type_checker_1.default.castableTypes(true);
|
|
@@ -252,7 +173,7 @@ const TypeEditor = ({ editing, autoFocus, type, onChange, visuallyActive }) => {
|
|
|
252
173
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
253
174
|
autoFocus: autoFocus, onChange: (evt) => {
|
|
254
175
|
onChange(evt.currentTarget.value);
|
|
255
|
-
}, className: (0, emotion_1.cx)(
|
|
176
|
+
}, className: (0, emotion_1.cx)(shared_1.editorStyles, typeEditor, visuallyActive && typeEditorActive), onClick: (e) => {
|
|
256
177
|
e.stopPropagation();
|
|
257
178
|
} }, TYPES.map((type) => {
|
|
258
179
|
return (react_1.default.createElement("option", { key: type, value: type, className: darkMode ? typeEditorOptionDark : typeEditorOptionLight }, type));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../src/components/document-list/element.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EAEV,OAAO,IAAI,iBAAiB,EAC7B,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../src/components/document-list/element.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EAEV,OAAO,IAAI,iBAAiB,EAC7B,MAAM,iBAAiB,CAAC;AAyazB,eAAO,MAAM,6BAA6B,GAAI,mEAK3C;IACD,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB,EAAE,OAAO,CAAC;IACnC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,WAeA,CAAC;AAYF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,GACrC,SAAS,iBAAiB,KACzB,MAcF,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAClD,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,KAAK,IAAI,CAAC;IACpE,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC1C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,CAwcA,CAAC"}
|