@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,112 @@
|
|
|
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.DateTimePicker = DateTimePicker;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
39
|
+
const leafygreen_1 = require("../leafygreen");
|
|
40
|
+
const use_theme_1 = require("../../hooks/use-theme");
|
|
41
|
+
const format_date_1 = require("../../utils/format-date");
|
|
42
|
+
const containerStyles = (0, emotion_1.css)({
|
|
43
|
+
display: 'flex',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
});
|
|
46
|
+
const buttonStyles = (0, emotion_1.css)({
|
|
47
|
+
display: 'flex',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
padding: 0,
|
|
50
|
+
margin: 0,
|
|
51
|
+
border: 'none',
|
|
52
|
+
background: 'none',
|
|
53
|
+
color: 'inherit',
|
|
54
|
+
cursor: 'pointer',
|
|
55
|
+
});
|
|
56
|
+
// We are not showing the native input at all. This is mainly due to how its
|
|
57
|
+
// rendered in Safari. For Chrome/Firefox, we can hide the input and only show
|
|
58
|
+
// the picker icon, but that's not possible in Safari. So we hide everything
|
|
59
|
+
// and use our custom button to open the picker.
|
|
60
|
+
const dateTimePickerInput = (0, emotion_1.css)({
|
|
61
|
+
colorScheme: 'light',
|
|
62
|
+
width: 0,
|
|
63
|
+
padding: 0,
|
|
64
|
+
border: 'none',
|
|
65
|
+
boxShadow: 'none',
|
|
66
|
+
outline: 'none',
|
|
67
|
+
'&::-webkit-calendar-picker-indicator': {
|
|
68
|
+
display: 'none',
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
const dateTimePickerInputDarkMode = (0, emotion_1.css)({
|
|
72
|
+
// This is the only bit we can customize in the native picker popup.
|
|
73
|
+
colorScheme: 'dark',
|
|
74
|
+
});
|
|
75
|
+
function DateTimePicker({ value, onChange, }) {
|
|
76
|
+
const pickerInputRef = (0, react_1.useRef)(null);
|
|
77
|
+
const darkMode = (0, use_theme_1.useDarkMode)();
|
|
78
|
+
const pickerDateTime = (0, format_date_1.convertToPickerDateTime)(value);
|
|
79
|
+
// On Firefox, when we clear the input value using `Clear` option from the
|
|
80
|
+
// picker, the input value is set to empty string. And then on following
|
|
81
|
+
// change in value, input.onChange is not called. So just before opening
|
|
82
|
+
// the picker, if the (datetime) value is empty, we set the this value to
|
|
83
|
+
// current date time so that the picker change is picked up.
|
|
84
|
+
const [seededDateTime, setSeededDateTime] = (0, react_1.useState)(null);
|
|
85
|
+
const openPicker = (0, react_1.useCallback)(() => {
|
|
86
|
+
const input = pickerInputRef.current;
|
|
87
|
+
if (!input) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (!pickerDateTime) {
|
|
91
|
+
setSeededDateTime((0, format_date_1.convertToPickerDateTime)(new Date().toString()));
|
|
92
|
+
}
|
|
93
|
+
input.focus();
|
|
94
|
+
input.showPicker();
|
|
95
|
+
}, [pickerDateTime]);
|
|
96
|
+
return (react_1.default.createElement("span", { className: containerStyles },
|
|
97
|
+
react_1.default.createElement("button", { type: "button", "aria-label": "Select date and time", "data-testid": "hadron-document-date-picker-button",
|
|
98
|
+
// The picker is only reachable by clicking its button, so that tabbing
|
|
99
|
+
// keeps moving between the editors.
|
|
100
|
+
tabIndex: -1, className: buttonStyles, onClick: openPicker },
|
|
101
|
+
react_1.default.createElement(leafygreen_1.Icon, { glyph: "Calendar", size: "small" })),
|
|
102
|
+
react_1.default.createElement("input", { ref: pickerInputRef, type: "datetime-local",
|
|
103
|
+
// Milliseconds precision, matching BSON dates. On chromium, this is the
|
|
104
|
+
// way to show milliseconds in the picker panel. On Firefox and Safari,
|
|
105
|
+
// time picker UI is not available at all.
|
|
106
|
+
step: "0.001", "data-testid": "hadron-document-date-picker", value: pickerDateTime || seededDateTime || '', tabIndex: -1, onBlur: () => {
|
|
107
|
+
setSeededDateTime(null);
|
|
108
|
+
}, onChange: (evt) => {
|
|
109
|
+
setSeededDateTime(null);
|
|
110
|
+
onChange((0, format_date_1.convertFromPickerDateTime)(evt.currentTarget.value));
|
|
111
|
+
}, className: (0, emotion_1.cx)(dateTimePickerInput, darkMode && dateTimePickerInputDarkMode) })));
|
|
112
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Exported for tests only.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatDateWithTimezone(value: Date | number | string, timezone?: string, locale?: string): string;
|
|
7
|
+
export declare function DateWithTimezoneHint({ value, children, }: {
|
|
8
|
+
value: Date | number | string;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
//# sourceMappingURL=date-with-timezone-hint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-with-timezone-hint.d.ts","sourceRoot":"","sources":["../../../src/components/document-list/date-with-timezone-hint.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAgBvC;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAC7B,QAAQ,SAAQ,EAChB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAiBR;AAkBD,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,qBAkBA"}
|
|
@@ -0,0 +1,95 @@
|
|
|
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.formatDateWithTimezone = formatDateWithTimezone;
|
|
37
|
+
exports.DateWithTimezoneHint = DateWithTimezoneHint;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
40
|
+
const inline_definition_1 = require("../inline-definition");
|
|
41
|
+
const bson_display_options_context_1 = require("./bson-display-options-context");
|
|
42
|
+
const bson_utils_1 = require("./bson-utils");
|
|
43
|
+
function isValidTimezone(timezone) {
|
|
44
|
+
try {
|
|
45
|
+
new Intl.DateTimeFormat('en-US', { timeZone: timezone });
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Exported for tests only.
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
function formatDateWithTimezone(value, timezone = 'UTC', locale) {
|
|
57
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
58
|
+
if (isNaN(date.valueOf())) {
|
|
59
|
+
return 'Invalid Date';
|
|
60
|
+
}
|
|
61
|
+
const timeZone = isValidTimezone(timezone) ? timezone : 'UTC';
|
|
62
|
+
try {
|
|
63
|
+
return new Intl.DateTimeFormat(locale, {
|
|
64
|
+
timeZone,
|
|
65
|
+
dateStyle: 'long',
|
|
66
|
+
timeStyle: 'long',
|
|
67
|
+
}).format(date);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return 'Invalid Date';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Inline styles to make things more easily copy-pasteable.
|
|
74
|
+
const containerStyles = (0, emotion_1.css)({
|
|
75
|
+
display: 'inline',
|
|
76
|
+
whiteSpace: 'normal',
|
|
77
|
+
[bson_utils_1.bsonValueDisplayVar]: 'inline',
|
|
78
|
+
});
|
|
79
|
+
const valueStyles = (0, emotion_1.css)({
|
|
80
|
+
display: 'inline',
|
|
81
|
+
paddingRight: '8px',
|
|
82
|
+
});
|
|
83
|
+
const dateWithTimezoneHintStyles = (0, emotion_1.css)({
|
|
84
|
+
userSelect: 'none',
|
|
85
|
+
});
|
|
86
|
+
function DateWithTimezoneHint({ value, children, }) {
|
|
87
|
+
const { timezone } = (0, bson_display_options_context_1.useBSONDisplayOptions)();
|
|
88
|
+
const timezoneFormattedValue = (0, react_1.useMemo)(() => {
|
|
89
|
+
return formatDateWithTimezone(value, timezone);
|
|
90
|
+
}, [value, timezone]);
|
|
91
|
+
return (react_1.default.createElement("span", { className: containerStyles },
|
|
92
|
+
react_1.default.createElement("span", { className: valueStyles }, children),
|
|
93
|
+
react_1.default.createElement("wbr", null),
|
|
94
|
+
react_1.default.createElement(inline_definition_1.InlineDefinition, { className: dateWithTimezoneHintStyles, "data-testid": "date-with-timezone-hint", definition: "This personal timezone display preference may be configured in Compass Settings." }, timezoneFormattedValue)));
|
|
95
|
+
}
|
|
@@ -7,6 +7,7 @@ declare const EditActionsFooter: React.FunctionComponent<{
|
|
|
7
7
|
modified?: boolean;
|
|
8
8
|
validationError?: Error | null;
|
|
9
9
|
alwaysForceUpdate?: boolean;
|
|
10
|
+
renderStatusMessage?(message: string): React.ReactNode;
|
|
10
11
|
onUpdate(force: boolean): void;
|
|
11
12
|
onDelete(): void;
|
|
12
13
|
onCancel?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-edit-actions-footer.d.ts","sourceRoot":"","sources":["../../../src/components/document-list/document-edit-actions-footer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,cAAc,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"document-edit-actions-footer.d.ts","sourceRoot":"","sources":["../../../src/components/document-list/document-edit-actions-footer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,cAAc,MAAM,iBAAiB,CAAC;AAqSlD,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAC/C,GAAG,EAAE,cAAc,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IAC/B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mBAAmB,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IACvD,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,QAAQ,IAAI,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAmGA,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -217,9 +217,6 @@ const container = (0, emotion_1.css)({
|
|
|
217
217
|
borderBottomLeftRadius: 'inherit',
|
|
218
218
|
borderBottomRightRadius: 'inherit',
|
|
219
219
|
});
|
|
220
|
-
const message = (0, emotion_1.css)({
|
|
221
|
-
overflow: 'scroll',
|
|
222
|
-
});
|
|
223
220
|
const buttonGroup = (0, emotion_1.css)({
|
|
224
221
|
display: 'flex',
|
|
225
222
|
marginLeft: 'auto',
|
|
@@ -263,7 +260,7 @@ function getColorStyles(status, darkMode) {
|
|
|
263
260
|
};
|
|
264
261
|
}
|
|
265
262
|
}
|
|
266
|
-
const EditActionsFooter = ({ doc, editing, deleting, modified = false, validationError: initialError = null, alwaysForceUpdate = false, onUpdate, onDelete, onCancel, }) => {
|
|
263
|
+
const EditActionsFooter = ({ doc, editing, deleting, modified = false, validationError: initialError = null, alwaysForceUpdate = false, renderStatusMessage = (message) => message, onUpdate, onDelete, onCancel, }) => {
|
|
267
264
|
const { status: _status, updateStatus, error, } = useHadronDocumentStatus(doc, editing, deleting, initialError);
|
|
268
265
|
const darkMode = (0, use_theme_1.useDarkMode)();
|
|
269
266
|
// Allow props to override event based status of the document (helpful for
|
|
@@ -279,7 +276,7 @@ const EditActionsFooter = ({ doc, editing, deleting, modified = false, validatio
|
|
|
279
276
|
return null;
|
|
280
277
|
}
|
|
281
278
|
return (react_1.default.createElement("div", { className: container, style: getColorStyles(status, darkMode), "data-testid": "document-footer", "data-status": status },
|
|
282
|
-
react_1.default.createElement("div", {
|
|
279
|
+
react_1.default.createElement("div", { "data-testid": "document-footer-message" }, renderStatusMessage(error?.message ?? statusMessage)),
|
|
283
280
|
!isSuccess(status) && (react_1.default.createElement("div", { className: buttonGroup },
|
|
284
281
|
error?.details && (react_1.default.createElement(leafygreen_1.Button, { className: button, size: "xsmall", onClick: () => (0, use_error_details_1.showErrorDetails)({
|
|
285
282
|
details: error.details,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/components/document-list/document.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EACV,OAAO,IAAI,kBAAkB,EAE9B,MAAM,iBAAiB,CAAC;AA0EzB,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAC5C,KAAK,EAAE,kBAAkB,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,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;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/components/document-list/document.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EACV,OAAO,IAAI,kBAAkB,EAE9B,MAAM,iBAAiB,CAAC;AA0EzB,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAC5C,KAAK,EAAE,kBAAkB,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,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;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAgHA,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -103,8 +103,16 @@ const HadronDocument = ({ value: document, editable = false, editing = false, on
|
|
|
103
103
|
alignWithNestedExpandIcon: false,
|
|
104
104
|
extraGutterWidth,
|
|
105
105
|
}), [editable, extraGutterWidth]);
|
|
106
|
+
const emptyDocumentOffset = (0, react_1.useMemo)(() => (0, element_1.calculateShowMoreToggleOffset)({
|
|
107
|
+
editable,
|
|
108
|
+
level: 0,
|
|
109
|
+
alignWithNestedExpandIcon: true,
|
|
110
|
+
extraGutterWidth,
|
|
111
|
+
}), [editable, extraGutterWidth]);
|
|
106
112
|
return (react_1.default.createElement("div", { className: className },
|
|
107
113
|
react_1.default.createElement("div", { className: hadronDocument, "data-testid": "hadron-document", "data-id": document.uuid },
|
|
114
|
+
!editable && elements.length === 0 && (react_1.default.createElement("div", { "data-testid": "readonly-document-empty", style: { paddingLeft: emptyDocumentOffset } },
|
|
115
|
+
react_1.default.createElement("em", null, "(empty document)"))),
|
|
108
116
|
react_1.default.createElement(auto_focus_context_1.AutoFocusContext.Provider, { value: editing ? autoFocus : null }, visibleElements.map((el, idx) => {
|
|
109
117
|
return (react_1.default.createElement(element_1.HadronElement, { key: idx, value: el, editable: editable, editingEnabled: editing, onEditStart: editable
|
|
110
118
|
? (id, type) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-editor.d.ts","sourceRoot":"","sources":["../../../../src/components/document-list/editors/date-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAGtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AA+H5C,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,WAAW,qBA4Bb"}
|
|
@@ -0,0 +1,135 @@
|
|
|
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.DateEditor = DateEditor;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
39
|
+
const leafygreen_1 = require("../../leafygreen");
|
|
40
|
+
const input_editor_1 = require("./input-editor");
|
|
41
|
+
const use_theme_1 = require("../../../hooks/use-theme");
|
|
42
|
+
const format_date_1 = require("../../../utils/format-date");
|
|
43
|
+
const editor_with_label_1 = require("./editor-with-label");
|
|
44
|
+
const date_with_timezone_hint_1 = require("../date-with-timezone-hint");
|
|
45
|
+
// Inline so the timezone info is on the same line unless it overflows.
|
|
46
|
+
const dateContainerStyles = (0, emotion_1.css)({
|
|
47
|
+
display: 'inline-flex',
|
|
48
|
+
verticalAlign: 'bottom',
|
|
49
|
+
});
|
|
50
|
+
const dateTimePickerContainerStyles = (0, emotion_1.css)({
|
|
51
|
+
display: 'flex',
|
|
52
|
+
alignItems: 'center',
|
|
53
|
+
});
|
|
54
|
+
const dateTimePickerButtonStyles = (0, emotion_1.css)({
|
|
55
|
+
display: 'flex',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
padding: 0,
|
|
58
|
+
margin: 0,
|
|
59
|
+
border: 'none',
|
|
60
|
+
background: 'none',
|
|
61
|
+
color: 'inherit',
|
|
62
|
+
cursor: 'pointer',
|
|
63
|
+
});
|
|
64
|
+
// We are not showing the native input at all. This is mainly due to how its
|
|
65
|
+
// rendered in Safari. For Chrome/Firefox, we can hide the input and only show
|
|
66
|
+
// the picker icon, but that's not possible in Safari. So we hide everything
|
|
67
|
+
// and use our custom button to open the picker.
|
|
68
|
+
const dateTimePickerInputStyles = (0, emotion_1.css)({
|
|
69
|
+
colorScheme: 'light',
|
|
70
|
+
width: 0,
|
|
71
|
+
height: 0,
|
|
72
|
+
padding: 0,
|
|
73
|
+
border: 'none',
|
|
74
|
+
boxShadow: 'none',
|
|
75
|
+
outline: 'none',
|
|
76
|
+
'&::-webkit-calendar-picker-indicator': {
|
|
77
|
+
display: 'none',
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
const dateTimePickerInputDarkModeStyles = (0, emotion_1.css)({
|
|
81
|
+
// This is the only bit we can customize in the native picker popup.
|
|
82
|
+
colorScheme: 'dark',
|
|
83
|
+
});
|
|
84
|
+
function DateTimePicker({ value, onChange, }) {
|
|
85
|
+
const pickerInputRef = (0, react_1.useRef)(null);
|
|
86
|
+
const darkMode = (0, use_theme_1.useDarkMode)();
|
|
87
|
+
const pickerDateTime = (0, format_date_1.convertToPickerDateTime)(value);
|
|
88
|
+
// On Firefox, when we clear the input value using `Clear` option from the
|
|
89
|
+
// picker, the input value is set to empty string. And then on following
|
|
90
|
+
// change in value, input.onChange is not called. So just before opening
|
|
91
|
+
// the picker, if the (datetime) value is empty, we set the this value to
|
|
92
|
+
// current date time so that the picker change is picked up.
|
|
93
|
+
const [seededDateTime, setSeededDateTime] = (0, react_1.useState)(null);
|
|
94
|
+
const openPicker = (0, react_1.useCallback)(() => {
|
|
95
|
+
const input = pickerInputRef.current;
|
|
96
|
+
if (!input) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!pickerDateTime) {
|
|
100
|
+
setSeededDateTime((0, format_date_1.convertToPickerDateTime)(new Date().toString()));
|
|
101
|
+
}
|
|
102
|
+
input.focus();
|
|
103
|
+
input.showPicker();
|
|
104
|
+
}, [pickerDateTime]);
|
|
105
|
+
return (react_1.default.createElement("span", { className: dateTimePickerContainerStyles },
|
|
106
|
+
react_1.default.createElement("button", { type: "button", "aria-label": "Select date and time", "data-testid": "hadron-document-date-picker-button",
|
|
107
|
+
// The picker is only reachable by clicking its button, so that tabbing
|
|
108
|
+
// keeps moving between the editors.
|
|
109
|
+
tabIndex: -1, className: dateTimePickerButtonStyles, onClick: openPicker },
|
|
110
|
+
react_1.default.createElement(leafygreen_1.Icon, { glyph: "Calendar", size: "small" })),
|
|
111
|
+
react_1.default.createElement("input", { ref: pickerInputRef, type: "datetime-local",
|
|
112
|
+
// Milliseconds precision, matching BSON dates. On chromium, this is the
|
|
113
|
+
// way to show milliseconds in the picker panel. On Firefox and Safari,
|
|
114
|
+
// time picker UI is not available at all.
|
|
115
|
+
step: "0.001", "data-testid": "hadron-document-date-picker", value: pickerDateTime || seededDateTime || '', tabIndex: -1, onBlur: () => {
|
|
116
|
+
setSeededDateTime(null);
|
|
117
|
+
}, onChange: (evt) => {
|
|
118
|
+
setSeededDateTime(null);
|
|
119
|
+
onChange((0, format_date_1.convertFromPickerDateTime)(evt.currentTarget.value));
|
|
120
|
+
}, className: (0, emotion_1.cx)(dateTimePickerInputStyles, darkMode && dateTimePickerInputDarkModeStyles) })));
|
|
121
|
+
}
|
|
122
|
+
function DateEditor({ value, onChange, onBlur, type, ...props }) {
|
|
123
|
+
const inputStyle = (0, react_1.useMemo)(() => {
|
|
124
|
+
// 29 because the ISODate format is 29 characters long
|
|
125
|
+
return { width: `${Math.max(value.length, 29)}ch` };
|
|
126
|
+
}, [value]);
|
|
127
|
+
return (react_1.default.createElement(date_with_timezone_hint_1.DateWithTimezoneHint, { value: value },
|
|
128
|
+
react_1.default.createElement("span", { className: dateContainerStyles },
|
|
129
|
+
react_1.default.createElement(editor_with_label_1.EditorWithLabel, { type: type },
|
|
130
|
+
react_1.default.createElement(input_editor_1.InputEditor, { value: value, onChange: onChange, onBlur: onBlur, ...props, style: inputStyle })),
|
|
131
|
+
react_1.default.createElement(DateTimePicker, { value: value, onChange: (newValue) => {
|
|
132
|
+
onChange(newValue);
|
|
133
|
+
onBlur();
|
|
134
|
+
} }))));
|
|
135
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-editor.d.ts","sourceRoot":"","sources":["../../../../src/components/document-list/editors/default-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,qBASnE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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.DefaultEditor = DefaultEditor;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const input_editor_1 = require("./input-editor");
|
|
39
|
+
const editor_with_label_1 = require("./editor-with-label");
|
|
40
|
+
function DefaultEditor({ value, type, ...props }) {
|
|
41
|
+
const inputStyle = (0, react_1.useMemo)(() => {
|
|
42
|
+
return { width: `${Math.max(value.length, 1)}ch` };
|
|
43
|
+
}, [value]);
|
|
44
|
+
return (react_1.default.createElement(editor_with_label_1.EditorWithLabel, { type: type },
|
|
45
|
+
react_1.default.createElement(input_editor_1.InputEditor, { value: value, ...props, style: inputStyle })));
|
|
46
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TypeCastMap } from 'hadron-type-checker';
|
|
3
|
+
export declare function EditorWithLabel({ type, children, }: {
|
|
4
|
+
type: keyof TypeCastMap;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}): React.JSX.Element;
|
|
7
|
+
//# sourceMappingURL=editor-with-label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-with-label.d.ts","sourceRoot":"","sources":["../../../../src/components/document-list/editors/editor-with-label.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAcvD,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,MAAM,WAAW,CAAC;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,qBAUA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EditorWithLabel = EditorWithLabel;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
9
|
+
const bson_utils_1 = require("../bson-utils");
|
|
10
|
+
const containerStyles = (0, emotion_1.css)({
|
|
11
|
+
display: 'inline-flex',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
maxWidth: '100%',
|
|
14
|
+
});
|
|
15
|
+
const labelStyles = (0, emotion_1.css)({
|
|
16
|
+
userSelect: 'none',
|
|
17
|
+
whiteSpace: 'nowrap',
|
|
18
|
+
});
|
|
19
|
+
function EditorWithLabel({ type, children, }) {
|
|
20
|
+
const label = bson_utils_1.BSON_TYPE_LABEL[type];
|
|
21
|
+
const bsonStyles = (0, bson_utils_1.useBsonThemeStyles)(type);
|
|
22
|
+
return (react_1.default.createElement("div", { className: containerStyles, style: bsonStyles },
|
|
23
|
+
label && react_1.default.createElement("span", { className: labelStyles },
|
|
24
|
+
label,
|
|
25
|
+
"('"),
|
|
26
|
+
children,
|
|
27
|
+
label && react_1.default.createElement("span", { className: labelStyles }, "')")));
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-editor.d.ts","sourceRoot":"","sources":["../../../../src/components/document-list/editors/input-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAK5C,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,EACT,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,qBA4B3B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.InputEditor = InputEditor;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
9
|
+
const shared_1 = require("./shared");
|
|
10
|
+
const use_theme_1 = require("../../../hooks/use-theme");
|
|
11
|
+
// Base single-line editor shared by the default, date and UUID editors. Callers
|
|
12
|
+
// only need to provide the value handling and their own width / placeholder.
|
|
13
|
+
function InputEditor({ value, valid, onChange, autoFocus, onBlur, className, ...props }) {
|
|
14
|
+
const darkMode = (0, use_theme_1.useDarkMode)();
|
|
15
|
+
return (react_1.default.createElement("input", { ...props, type: "text", "data-testid": "hadron-document-value-editor", value: value, onChange: (evt) => {
|
|
16
|
+
onChange(evt.currentTarget.value);
|
|
17
|
+
}, onBlur: onBlur,
|
|
18
|
+
// See ../element.tsx
|
|
19
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
20
|
+
autoFocus: autoFocus, className: (0, emotion_1.cx)(shared_1.editorStyles, !valid && shared_1.editorInvalidStyles, !valid &&
|
|
21
|
+
(darkMode
|
|
22
|
+
? shared_1.editorInvalidDarkModeStyles
|
|
23
|
+
: shared_1.editorInvalidLightModeStyles), className), spellCheck: "false" }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { TypeCastMap } from 'hadron-type-checker';
|
|
3
|
+
export declare const editorStyles: string;
|
|
4
|
+
export declare const editorInvalidStyles: string;
|
|
5
|
+
export declare const editorInvalidLightModeStyles: string;
|
|
6
|
+
export declare const editorInvalidDarkModeStyles: string;
|
|
7
|
+
export type EditorInputProps = Omit<React.HTMLProps<HTMLInputElement>, 'value' | 'onChange' | 'onBlur' | 'autoFocus'>;
|
|
8
|
+
export type EditorProps = {
|
|
9
|
+
autoFocus?: boolean;
|
|
10
|
+
value: string;
|
|
11
|
+
valid: boolean;
|
|
12
|
+
onChange(newValue: string): void;
|
|
13
|
+
onBlur(): void;
|
|
14
|
+
type: keyof TypeCastMap;
|
|
15
|
+
} & EditorInputProps;
|
|
16
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../src/components/document-list/editors/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAmBvD,eAAO,MAAM,YAAY,QAAiC,CAAC;AAE3D,eAAO,MAAM,mBAAmB,QAI9B,CAAC;AAEH,eAAO,MAAM,4BAA4B,QAGvC,CAAC;AAEH,eAAO,MAAM,2BAA2B,QAGtC,CAAC;AAIH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,EACjC,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,CAC9C,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,MAAM,IAAI,IAAI,CAAC;IACf,IAAI,EAAE,MAAM,WAAW,CAAC;CACzB,GAAG,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.editorInvalidDarkModeStyles = exports.editorInvalidLightModeStyles = exports.editorInvalidStyles = exports.editorStyles = void 0;
|
|
4
|
+
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
5
|
+
const palette_1 = require("@leafygreen-ui/palette");
|
|
6
|
+
const editorReset = (0, emotion_1.css)({
|
|
7
|
+
padding: 0,
|
|
8
|
+
margin: 0,
|
|
9
|
+
border: 'none',
|
|
10
|
+
boxShadow: 'none',
|
|
11
|
+
outline: 'none',
|
|
12
|
+
backgroundColor: 'transparent',
|
|
13
|
+
maxWidth: '100%',
|
|
14
|
+
});
|
|
15
|
+
const editorOutline = (0, emotion_1.css)({
|
|
16
|
+
'&:focus, &:active': {
|
|
17
|
+
borderRadius: `2px`,
|
|
18
|
+
boxShadow: `0 0 0 2px ${palette_1.palette.blue.light1}`,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
exports.editorStyles = (0, emotion_1.cx)(editorReset, editorOutline);
|
|
22
|
+
exports.editorInvalidStyles = (0, emotion_1.css)({
|
|
23
|
+
'&:focus, &:active': {
|
|
24
|
+
boxShadow: `0 0 0 2px ${palette_1.palette.red.dark2}`,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
exports.editorInvalidLightModeStyles = (0, emotion_1.css)({
|
|
28
|
+
backgroundColor: palette_1.palette.red.light2,
|
|
29
|
+
color: palette_1.palette.red.dark2,
|
|
30
|
+
});
|
|
31
|
+
exports.editorInvalidDarkModeStyles = (0, emotion_1.css)({
|
|
32
|
+
backgroundColor: palette_1.palette.red.dark2,
|
|
33
|
+
color: palette_1.palette.red.light2,
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-editor.d.ts","sourceRoot":"","sources":["../../../../src/components/document-list/editors/text-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAKvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAqB5C,wBAAgB,UAAU,CAAC,EACzB,KAAK,EAAE,GAAG,EACV,KAAK,EACL,QAAQ,EACR,SAAS,EACT,MAAM,EACN,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,qBA+C3B"}
|