@mongodb-js/compass-components 0.5.0 → 0.9.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/lib/compass-ui-colors.d.ts +3 -0
- package/lib/compass-ui-colors.js +7 -0
- package/lib/compass-ui-colors.js.map +1 -0
- package/lib/components/accordion.d.ts +7 -0
- package/lib/components/accordion.js +71 -0
- package/lib/components/accordion.js.map +1 -0
- package/lib/components/cancel-loader.d.ts +8 -0
- package/lib/components/cancel-loader.js +64 -0
- package/lib/components/cancel-loader.js.map +1 -0
- package/lib/components/confirmation-modal.d.ts +3 -1
- package/lib/components/confirmation-modal.js +5 -0
- package/lib/components/confirmation-modal.js.map +1 -1
- package/lib/components/content-with-fallback.d.ts +17 -0
- package/lib/components/content-with-fallback.js +119 -0
- package/lib/components/content-with-fallback.js.map +1 -0
- package/lib/components/file-input.d.ts +20 -0
- package/lib/components/file-input.js +121 -0
- package/lib/components/file-input.js.map +1 -0
- package/lib/components/inline-definition.d.ts +7 -0
- package/lib/components/inline-definition.js +31 -0
- package/lib/components/inline-definition.js.map +1 -0
- package/lib/components/placeholder.d.ts +8 -0
- package/lib/components/placeholder.js +68 -0
- package/lib/components/placeholder.js.map +1 -0
- package/lib/components/resize-handle.d.ts +15 -0
- package/lib/components/resize-handle.js +117 -0
- package/lib/components/resize-handle.js.map +1 -0
- package/lib/components/spin-loader.d.ts +12 -0
- package/lib/components/spin-loader.js +53 -0
- package/lib/components/spin-loader.js.map +1 -0
- package/lib/components/tooltip.d.ts +13 -0
- package/lib/components/tooltip.js +52 -0
- package/lib/components/tooltip.js.map +1 -0
- package/lib/hooks/use-dom-rect.d.ts +5 -0
- package/lib/hooks/use-dom-rect.js +28 -0
- package/lib/hooks/use-dom-rect.js.map +1 -0
- package/lib/hooks/use-focus-hover.d.ts +14 -0
- package/lib/hooks/use-focus-hover.js +57 -0
- package/lib/hooks/use-focus-hover.js.map +1 -0
- package/lib/index.d.ts +39 -1
- package/lib/index.js +132 -1
- package/lib/index.js.map +1 -1
- package/lib/utils/merge-props.d.ts +2 -0
- package/lib/utils/merge-props.js +24 -0
- package/lib/utils/merge-props.js.map +1 -0
- package/package.json +45 -11
- package/lib/.esm-wrapper.mjs +0 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transparentWhite = exports.transparentGray = exports.gray8 = void 0;
|
|
4
|
+
exports.gray8 = '#f5f6f7';
|
|
5
|
+
exports.transparentGray = 'rgba(180, 180, 180, 0.5)';
|
|
6
|
+
exports.transparentWhite = 'rgba(255, 255, 255, 0.5)';
|
|
7
|
+
//# sourceMappingURL=compass-ui-colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compass-ui-colors.js","sourceRoot":"","sources":["../src/compass-ui-colors.tsx"],"names":[],"mappings":";;;AAAa,QAAA,KAAK,GAAG,SAAS,CAAC;AAClB,QAAA,eAAe,GAAG,0BAA0B,CAAC;AAC7C,QAAA,gBAAgB,GAAG,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const react_1 = __importStar(require("react"));
|
|
26
|
+
const tokens_1 = require("@leafygreen-ui/tokens");
|
|
27
|
+
const css_1 = require("@emotion/css");
|
|
28
|
+
const icon_1 = __importDefault(require("@leafygreen-ui/icon"));
|
|
29
|
+
const palette_1 = require("@leafygreen-ui/palette");
|
|
30
|
+
const utils_1 = require("@react-aria/utils");
|
|
31
|
+
const labelStyles = (0, css_1.css)({
|
|
32
|
+
padding: 0,
|
|
33
|
+
margin: 0,
|
|
34
|
+
fontWeight: 'bold',
|
|
35
|
+
});
|
|
36
|
+
const buttonStyles = (0, css_1.css)({
|
|
37
|
+
display: 'flex',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
border: 'none',
|
|
40
|
+
background: 'none',
|
|
41
|
+
borderRadius: '6px',
|
|
42
|
+
boxShadow: 'none',
|
|
43
|
+
transition: 'box-shadow 150ms ease-in-out',
|
|
44
|
+
'&:focus-visible': {
|
|
45
|
+
boxShadow: `0 0 0 3px ${palette_1.uiColors.focus}`,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
const containerStyles = (0, css_1.css)({
|
|
49
|
+
marginTop: tokens_1.spacing[3],
|
|
50
|
+
display: 'flex',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
});
|
|
53
|
+
const buttonIconStyles = (0, css_1.css)({
|
|
54
|
+
marginRight: tokens_1.spacing[1],
|
|
55
|
+
});
|
|
56
|
+
function Accordion(props) {
|
|
57
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
58
|
+
const regionId = (0, utils_1.useId)('region-');
|
|
59
|
+
const labelId = (0, utils_1.useId)('label-');
|
|
60
|
+
return (react_1.default.createElement("div", { "data-testid": props.dataTestId },
|
|
61
|
+
react_1.default.createElement("div", { className: containerStyles },
|
|
62
|
+
react_1.default.createElement("p", { className: labelStyles, id: labelId },
|
|
63
|
+
react_1.default.createElement("button", { className: buttonStyles, type: "button", "aria-expanded": open ? 'true' : 'false', "aria-controls": regionId, onClick: () => {
|
|
64
|
+
setOpen((currentOpen) => !currentOpen);
|
|
65
|
+
} },
|
|
66
|
+
react_1.default.createElement(icon_1.default, { className: buttonIconStyles, glyph: open ? 'ChevronDown' : 'ChevronRight' }),
|
|
67
|
+
props.text))),
|
|
68
|
+
open && (react_1.default.createElement("div", { role: "region", "aria-labelledby": labelId, id: regionId }, props.children))));
|
|
69
|
+
}
|
|
70
|
+
exports.default = Accordion;
|
|
71
|
+
//# sourceMappingURL=accordion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion.js","sourceRoot":"","sources":["../../src/components/accordion.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAwC;AACxC,kDAAgD;AAChD,sCAAmC;AACnC,+DAAuC;AACvC,oDAAkD;AAClD,6CAA0C;AAE1C,MAAM,WAAW,GAAG,IAAA,SAAG,EAAC;IACtB,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,UAAU,EAAE,MAAM;CACnB,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,IAAA,SAAG,EAAC;IACvB,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,QAAQ;IACpB,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,MAAM;IAClB,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,MAAM;IACjB,UAAU,EAAE,8BAA8B;IAC1C,iBAAiB,EAAE;QACjB,SAAS,EAAE,aAAa,kBAAQ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CAAC;AAED,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
const css_1 = require("@emotion/css");
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const cancelLoaderStyle = (0, css_1.css)({
|
|
9
|
+
height: '100%',
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexDirection: 'column',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
justifyContent: 'center',
|
|
14
|
+
padding: '10px 0',
|
|
15
|
+
});
|
|
16
|
+
const progressTextStyle = (0, css_1.css)({
|
|
17
|
+
margin: '0 auto 30px',
|
|
18
|
+
textAlign: 'left',
|
|
19
|
+
fontSize: '24px',
|
|
20
|
+
color: '#807f7f',
|
|
21
|
+
fontWeight: 200,
|
|
22
|
+
});
|
|
23
|
+
const spinnerStyle = (0, css_1.css)({
|
|
24
|
+
animation: 'fa-spin 2s infinite linear',
|
|
25
|
+
width: '40px',
|
|
26
|
+
textAlign: 'center',
|
|
27
|
+
display: 'inline-block',
|
|
28
|
+
textRendering: 'auto',
|
|
29
|
+
font: 'normal normal normal 20px/1 FontAwesome',
|
|
30
|
+
'&::before': {
|
|
31
|
+
boxSizing: 'border-box',
|
|
32
|
+
content: '"\\f1ce"',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const buttonStyle = (0, css_1.css)({
|
|
36
|
+
padding: '0 10px 0 10px',
|
|
37
|
+
height: '28px',
|
|
38
|
+
fontWeight: 'bold',
|
|
39
|
+
fontSize: '13px',
|
|
40
|
+
lineHeight: '26px',
|
|
41
|
+
textTransform: 'uppercase',
|
|
42
|
+
backgroundColor: 'transparent',
|
|
43
|
+
border: '1px solid #13AA52',
|
|
44
|
+
borderRadius: '3px',
|
|
45
|
+
boxShadow: 'none',
|
|
46
|
+
color: '#13AA52',
|
|
47
|
+
fontFamily: 'Akzidenz',
|
|
48
|
+
'-webkit-appearance': 'button',
|
|
49
|
+
cursor: 'pointer',
|
|
50
|
+
overflow: 'visible',
|
|
51
|
+
margin: 0,
|
|
52
|
+
boxSizing: 'border-box',
|
|
53
|
+
outline: 'none',
|
|
54
|
+
});
|
|
55
|
+
function CancelLoader({ dataTestId, progressText, cancelText, onCancel, }) {
|
|
56
|
+
return (react_1.default.createElement("div", { "data-testid": dataTestId, className: cancelLoaderStyle },
|
|
57
|
+
react_1.default.createElement("div", { className: progressTextStyle },
|
|
58
|
+
react_1.default.createElement("i", { className: spinnerStyle }),
|
|
59
|
+
progressText),
|
|
60
|
+
react_1.default.createElement("div", null,
|
|
61
|
+
react_1.default.createElement("button", { className: buttonStyle, onClick: onCancel }, cancelText))));
|
|
62
|
+
}
|
|
63
|
+
exports.default = CancelLoader;
|
|
64
|
+
//# sourceMappingURL=cancel-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancel-loader.js","sourceRoot":"","sources":["../../src/components/cancel-loader.tsx"],"names":[],"mappings":";;;;;AAAA,sCAAmC;AACnC,kDAA0B;AAE1B,MAAM,iBAAiB,GAAG,IAAA,SAAG,EAAC;IAC5B,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,QAAQ;IACvB,UAAU,EAAE,QAAQ;IACpB,cAAc,EAAE,QAAQ;IACxB,OAAO,EAAE,QAAQ;CAClB,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,IAAA,SAAG,EAAC;IAC5B,MAAM,EAAE,aAAa;IACrB,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,SAAS;IAChB,UAAU,EAAE,GAAG;CAChB,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,IAAA,SAAG,EAAC;IACvB,SAAS,EAAE,4BAA4B;IACvC,KAAK,EAAE,MAAM;IACb,SAAS,EAAE,QAAQ;IACnB,OAAO,EAAE,cAAc;IACvB,aAAa,EAAE,MAAM;IACrB,IAAI,EAAE,yCAAyC;IAC/C,WAAW,EAAE;QACX,SAAS,EAAE,YAAY;QACvB,OAAO,EAAE,UAAU;KACpB;CACF,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,IAAA,SAAG,EAAC;IACtB,OAAO,EAAE,eAAe;IACxB,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,MAAM;IAClB,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,MAAM;IAClB,aAAa,EAAE,WAAW;IAC1B,eAAe,EAAE,aAAa;IAC9B,MAAM,EAAE,mBAAmB;IAC3B,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,MAAM;IACjB,KAAK,EAAE,SAAS;IAChB,UAAU,EAAE,UAAU;IACtB,oBAAoB,EAAE,QAAQ;IAC9B,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,SAAS;IACnB,MAAM,EAAE,CAAC;IACT,SAAS,EAAE,YAAY;IACvB,OAAO,EAAE,MAAM;CAChB,CAAC,CAAC;AAEH,SAAS,YAAY,CAAC,EACpB,UAAU,EACV,YAAY,EACZ,UAAU,EACV,QAAQ,GAMT;IACC,OAAO,CACL,sDAAkB,UAAU,EAAE,SAAS,EAAE,iBAAiB;QACxD,uCAAK,SAAS,EAAE,iBAAiB;YAC/B,qCAAG,SAAS,EAAE,YAAY,GAAI;YAC7B,YAAY,CACT;QACN;YACE,0CAAQ,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,IAC9C,UAAU,CACJ,CACL,CACF,CACP,CAAC;AACJ,CAAC;AAED,kBAAe,YAAY,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import LeafyGreenConfirmationModal from '@leafygreen-ui/confirmation-modal';
|
|
3
|
-
declare function ConfirmationModal(props: React.ComponentProps<typeof LeafyGreenConfirmationModal>
|
|
3
|
+
declare function ConfirmationModal(props: React.ComponentProps<typeof LeafyGreenConfirmationModal> & {
|
|
4
|
+
trackingId?: string;
|
|
5
|
+
}): React.ReactElement;
|
|
4
6
|
export default ConfirmationModal;
|
|
@@ -5,7 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const confirmation_modal_1 = __importDefault(require("@leafygreen-ui/confirmation-modal"));
|
|
8
|
+
const compass_logging_1 = require("@mongodb-js/compass-logging");
|
|
9
|
+
const { track } = (0, compass_logging_1.createLoggerAndTelemetry)('COMPASS-UI');
|
|
8
10
|
function ConfirmationModal(props) {
|
|
11
|
+
if (props.open && props.trackingId) {
|
|
12
|
+
track('Screen', { name: props.trackingId });
|
|
13
|
+
}
|
|
9
14
|
return react_1.default.createElement(confirmation_modal_1.default, { ...props });
|
|
10
15
|
}
|
|
11
16
|
exports.default = ConfirmationModal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirmation-modal.js","sourceRoot":"","sources":["../../src/components/confirmation-modal.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAC1B,2FAA4E;
|
|
1
|
+
{"version":3,"file":"confirmation-modal.js","sourceRoot":"","sources":["../../src/components/confirmation-modal.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAC1B,2FAA4E;AAC5E,iEAAuE;AACvE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,0CAAwB,EAAC,YAAY,CAAC,CAAC;AAEzD,SAAS,iBAAiB,CACxB,KAEC;IAED,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,UAAU,EAAE;QAClC,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;KAC7C;IACD,OAAO,8BAAC,4BAA2B,OAAK,KAAK,GAAI,CAAC;AACpD,CAAC;AAED,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const ContentWithFallback: React.FunctionComponent<{
|
|
3
|
+
content(shouldRender: boolean, shouldAnimate: boolean): React.ReactElement | boolean | null;
|
|
4
|
+
fallback(shouldRender: boolean): React.ReactElement | boolean | null;
|
|
5
|
+
isContentReady: boolean;
|
|
6
|
+
contentAfterFallbackTimeout?: number;
|
|
7
|
+
fallbackTimeout?: number;
|
|
8
|
+
}>;
|
|
9
|
+
declare type FadeInPlaceholderProps = {
|
|
10
|
+
isContentReady: boolean;
|
|
11
|
+
content(): React.ReactElement | boolean | null;
|
|
12
|
+
fallback(): React.ReactElement | boolean | null;
|
|
13
|
+
contentContainerProps?: React.HTMLProps<HTMLDivElement>;
|
|
14
|
+
fallbackContainerProps?: React.HTMLProps<HTMLDivElement>;
|
|
15
|
+
};
|
|
16
|
+
export declare const FadeInPlaceholder: React.FunctionComponent<FadeInPlaceholderProps & Omit<React.HTMLProps<HTMLDivElement>, keyof FadeInPlaceholderProps>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.FadeInPlaceholder = exports.ContentWithFallback = void 0;
|
|
23
|
+
const react_1 = __importStar(require("react"));
|
|
24
|
+
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
25
|
+
var RenderStatus;
|
|
26
|
+
(function (RenderStatus) {
|
|
27
|
+
RenderStatus["Nothing"] = "Nothing";
|
|
28
|
+
RenderStatus["Fallback"] = "Fallback";
|
|
29
|
+
RenderStatus["Content"] = "Content";
|
|
30
|
+
RenderStatus["ContentAnimated"] = "ContentAnimated";
|
|
31
|
+
})(RenderStatus || (RenderStatus = {}));
|
|
32
|
+
function isContent(status) {
|
|
33
|
+
return [RenderStatus.ContentAnimated, RenderStatus.Content].includes(status);
|
|
34
|
+
}
|
|
35
|
+
function useRenderWithFallback(isContentReady, { contentAfterFallbackTimeout = 200, fallbackTimeout = 30 } = {}) {
|
|
36
|
+
const [renderStatus, setRenderStatus] = (0, react_1.useState)(isContentReady ? RenderStatus.Content : RenderStatus.Nothing);
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
if (isContent(renderStatus)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (isContentReady && renderStatus === RenderStatus.Nothing) {
|
|
42
|
+
setRenderStatus(RenderStatus.Content);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (isContentReady && renderStatus === RenderStatus.Fallback) {
|
|
46
|
+
const timeout = setTimeout(() => {
|
|
47
|
+
setRenderStatus(RenderStatus.ContentAnimated);
|
|
48
|
+
}, contentAfterFallbackTimeout);
|
|
49
|
+
return () => {
|
|
50
|
+
clearTimeout(timeout);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (!isContentReady && renderStatus === RenderStatus.Nothing) {
|
|
54
|
+
const timeout = setTimeout(() => {
|
|
55
|
+
setRenderStatus(RenderStatus.Fallback);
|
|
56
|
+
}, fallbackTimeout);
|
|
57
|
+
return () => {
|
|
58
|
+
clearTimeout(timeout);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}, [
|
|
62
|
+
renderStatus,
|
|
63
|
+
isContentReady,
|
|
64
|
+
contentAfterFallbackTimeout,
|
|
65
|
+
fallbackTimeout,
|
|
66
|
+
]);
|
|
67
|
+
return renderStatus;
|
|
68
|
+
}
|
|
69
|
+
const ContentWithFallback = ({ content, fallback, isContentReady, contentAfterFallbackTimeout, fallbackTimeout, }) => {
|
|
70
|
+
const renderStatus = useRenderWithFallback(isContentReady, {
|
|
71
|
+
contentAfterFallbackTimeout,
|
|
72
|
+
fallbackTimeout,
|
|
73
|
+
});
|
|
74
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
75
|
+
content(isContent(renderStatus), renderStatus === RenderStatus.ContentAnimated),
|
|
76
|
+
fallback(renderStatus === RenderStatus.Fallback)));
|
|
77
|
+
};
|
|
78
|
+
exports.ContentWithFallback = ContentWithFallback;
|
|
79
|
+
const contentWithFallbackContainer = (0, emotion_1.css)({
|
|
80
|
+
position: 'relative',
|
|
81
|
+
});
|
|
82
|
+
const fadeInAnimation = (0, emotion_1.keyframes)({
|
|
83
|
+
from: {
|
|
84
|
+
opacity: 0,
|
|
85
|
+
},
|
|
86
|
+
to: {
|
|
87
|
+
opacity: 1,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
const contentContainer = (0, emotion_1.css)({
|
|
91
|
+
position: 'relative',
|
|
92
|
+
});
|
|
93
|
+
const contentContainerFadeIn = (0, emotion_1.css)({
|
|
94
|
+
animation: `${fadeInAnimation} .16s ease-out`,
|
|
95
|
+
});
|
|
96
|
+
const fallbackContainer = (0, emotion_1.css)({
|
|
97
|
+
position: 'absolute',
|
|
98
|
+
top: 0,
|
|
99
|
+
right: 0,
|
|
100
|
+
bottom: 0,
|
|
101
|
+
left: 0,
|
|
102
|
+
opacity: 0,
|
|
103
|
+
transition: 'opacity .16s ease-out',
|
|
104
|
+
pointerEvents: 'none',
|
|
105
|
+
});
|
|
106
|
+
const fallbackContainerVisible = (0, emotion_1.css)({
|
|
107
|
+
opacity: 1,
|
|
108
|
+
transitionTimingFunction: 'ease-in',
|
|
109
|
+
});
|
|
110
|
+
const FadeInPlaceholder = ({ content, fallback, isContentReady, contentContainerProps = {}, fallbackContainerProps = {}, className, ...props }) => {
|
|
111
|
+
return (react_1.default.createElement("div", { className: (0, emotion_1.cx)(contentWithFallbackContainer, className), ...props },
|
|
112
|
+
react_1.default.createElement(exports.ContentWithFallback, { isContentReady: isContentReady, content: (shouldRender, shouldAnimate) => {
|
|
113
|
+
return (shouldRender && (react_1.default.createElement("div", { ...contentContainerProps, className: (0, emotion_1.cx)(contentContainer, shouldAnimate && contentContainerFadeIn, contentContainerProps.className) }, content())));
|
|
114
|
+
}, fallback: (shouldRender) => {
|
|
115
|
+
return (react_1.default.createElement("div", { ...fallbackContainerProps, className: (0, emotion_1.cx)(fallbackContainer, shouldRender && fallbackContainerVisible, fallbackContainerProps.className) }, fallback()));
|
|
116
|
+
} })));
|
|
117
|
+
};
|
|
118
|
+
exports.FadeInPlaceholder = FadeInPlaceholder;
|
|
119
|
+
//# sourceMappingURL=content-with-fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-with-fallback.js","sourceRoot":"","sources":["../../src/components/content-with-fallback.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,+CAAmD;AACnD,oDAA4D;AAE5D,IAAK,YAOJ;AAPD,WAAK,YAAY;IACf,mCAAmB,CAAA;IACnB,qCAAqB,CAAA;IACrB,mCAAmB,CAAA;IAGnB,mDAAmC,CAAA;A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;CACtB,CAAC,CAAC;AAEH,MAAM,wBAAwB,GAAG,IAAA,aAAG,EAAC;IACnC,OAAO,EAAE,CAAC;IACV,wBAAwB,EAAE,SAAS;CACpC,CAAC,CAAC;AAUI,MAAM,iBAAiB,GAG1B,CAAC,EACH,OAAO,EACP,QAAQ,EACR,cAAc,EACd,qBAAqB,GAAG,EAAE,EAC1B,sBAAsB,GAAG,EAAE,EAC3B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,EAAE;IACH,OAAO,CACL,uCAAK,SAAS,EAAE,IAAA,YAAE,EAAC,4BAA4B,EAAE,SAAS,CAAC,KAAM,KAAK;QACpE,8BAAC,2BAAmB,IAClB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,EAAE;gBACvC,OAAO,CACL,YAAY,IAAI,CACd,0CACM,qBAAqB,EACzB,SAAS,EAAE,IAAA,YAAE,EACX,gBAAgB,EAChB,aAAa,IAAI,sBAAsB,EACvC,qBAAqB,CAAC,SAAS,CAChC,IAEA,OAAO,EAAE,CACN,CACP,CACF,CAAC;YACJ,CAAC,EACD,QAAQ,EAAE,CAAC,YAAY,EAAE,EAAE;gBACzB,OAAO,CACL,0CACM,sBAAsB,EAC1B,SAAS,EAAE,IAAA,YAAE,EACX,iBAAiB,EACjB,YAAY,IAAI,wBAAwB,EACxC,sBAAsB,CAAC,SAAS,CACjC,IAEA,QAAQ,EAAE,CACP,CACP,CAAC;YACJ,CAAC,GACoB,CACnB,CACP,CAAC;AACJ,CAAC,CAAC;AAjDW,QAAA,iBAAiB,qBAiD5B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare enum Variant {
|
|
3
|
+
Horizontal = "HORIZONTAL",
|
|
4
|
+
Vertical = "VERTICAL"
|
|
5
|
+
}
|
|
6
|
+
declare function FileInput({ id, label, dataTestId, onChange, multi, error, errorMessage, variant, link, description, values, labelAlignment, }: {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
dataTestId: string;
|
|
10
|
+
onChange: (files: string[]) => void;
|
|
11
|
+
multi?: boolean;
|
|
12
|
+
error?: boolean;
|
|
13
|
+
errorMessage?: string;
|
|
14
|
+
variant?: Variant;
|
|
15
|
+
link?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
values?: string[];
|
|
18
|
+
labelAlignment?: 'right' | 'left' | 'center';
|
|
19
|
+
}): React.ReactElement;
|
|
20
|
+
export default FileInput;
|
|
@@ -0,0 +1,121 @@
|
|
|
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.Variant = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
10
|
+
const palette_1 = require("@leafygreen-ui/palette");
|
|
11
|
+
const tokens_1 = require("@leafygreen-ui/tokens");
|
|
12
|
+
const __1 = require("..");
|
|
13
|
+
const { base: redBaseColor } = palette_1.uiColors.red;
|
|
14
|
+
const formItemHorizontalStyles = (0, emotion_1.css)({
|
|
15
|
+
marginTop: tokens_1.spacing[2],
|
|
16
|
+
marginBottom: tokens_1.spacing[2],
|
|
17
|
+
marginRight: 'auto',
|
|
18
|
+
marginLeft: 'auto',
|
|
19
|
+
display: 'flex',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
});
|
|
22
|
+
const formItemVerticalStyles = (0, emotion_1.css) `
|
|
23
|
+
margin: 5px auto 20px;
|
|
24
|
+
`;
|
|
25
|
+
const formItemErrorStyles = (0, emotion_1.css) `
|
|
26
|
+
border: 1px solid ${redBaseColor};
|
|
27
|
+
border-radius: 5px;
|
|
28
|
+
&:focus {
|
|
29
|
+
border: 1px solid ${redBaseColor};
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
const buttonStyles = (0, emotion_1.css) `
|
|
33
|
+
width: 100%;
|
|
34
|
+
`;
|
|
35
|
+
const errorMessageStyles = (0, emotion_1.css)({
|
|
36
|
+
color: `${redBaseColor} !important`,
|
|
37
|
+
});
|
|
38
|
+
const labelHorizontalStyles = (0, emotion_1.css)({
|
|
39
|
+
width: '70%',
|
|
40
|
+
display: 'grid',
|
|
41
|
+
gridTemplateAreas: `'label icon' 'description .'`,
|
|
42
|
+
gridTemplateColumns: '1fr auto',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
columnGap: tokens_1.spacing[1],
|
|
45
|
+
paddingRight: tokens_1.spacing[3],
|
|
46
|
+
});
|
|
47
|
+
const labelIconStyles = (0, emotion_1.css) `
|
|
48
|
+
display: inline-block;
|
|
49
|
+
vertical-align: middle;
|
|
50
|
+
font: normal normal normal 14px/1 FontAwesome;
|
|
51
|
+
font-size: inherit;
|
|
52
|
+
text-rendering: auto;
|
|
53
|
+
margin: 0 0 0 5px;
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
color: #bfbfbe;
|
|
56
|
+
|
|
57
|
+
&:link,
|
|
58
|
+
&:active {
|
|
59
|
+
color: #bfbfbe;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&:link,
|
|
63
|
+
&:active,
|
|
64
|
+
&:hover {
|
|
65
|
+
text-decoration: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&:hover {
|
|
69
|
+
color: #fbb129;
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
var Variant;
|
|
73
|
+
(function (Variant) {
|
|
74
|
+
Variant["Horizontal"] = "HORIZONTAL";
|
|
75
|
+
Variant["Vertical"] = "VERTICAL";
|
|
76
|
+
})(Variant = exports.Variant || (exports.Variant = {}));
|
|
77
|
+
function FileInput({ id, label, dataTestId, onChange, multi = false, error = false, errorMessage, variant = Variant.Horizontal, link, description, values, labelAlignment = 'left', }) {
|
|
78
|
+
const inputRef = react_1.default.useRef(null);
|
|
79
|
+
const buttonText = react_1.default.useMemo(() => {
|
|
80
|
+
if (Array.isArray(values) && values.length > 0) {
|
|
81
|
+
return values.map((file) => path_1.default.basename(file)).join(', ');
|
|
82
|
+
}
|
|
83
|
+
return multi ? 'Select files...' : 'Select a file...';
|
|
84
|
+
}, [values, multi]);
|
|
85
|
+
const onFilesChanged = react_1.default.useCallback((evt) => {
|
|
86
|
+
const fileList = Array.from(evt.currentTarget.files);
|
|
87
|
+
const files = fileList.map((file) => {
|
|
88
|
+
return file.path;
|
|
89
|
+
});
|
|
90
|
+
onChange(files);
|
|
91
|
+
}, [onChange]);
|
|
92
|
+
const renderDescription = () => {
|
|
93
|
+
if (!link && !description) {
|
|
94
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
95
|
+
}
|
|
96
|
+
if (!link) {
|
|
97
|
+
return (react_1.default.createElement(__1.Description, { "data-testid": 'file-input-description', style: { gridArea: 'description' } }, description));
|
|
98
|
+
}
|
|
99
|
+
return (react_1.default.createElement(__1.Link, { "data-testid": 'file-input-link', href: link, className: (0, emotion_1.cx)({
|
|
100
|
+
[labelIconStyles]: !description,
|
|
101
|
+
}, (0, emotion_1.css)({
|
|
102
|
+
gridArea: description ? 'description' : 'icon',
|
|
103
|
+
})), hideExternalIcon: !description }, description !== null && description !== void 0 ? description : ''));
|
|
104
|
+
};
|
|
105
|
+
return (react_1.default.createElement("div", null,
|
|
106
|
+
react_1.default.createElement("div", { className: (0, emotion_1.cx)({ [formItemHorizontalStyles]: variant === Variant.Horizontal }, { [formItemVerticalStyles]: variant === Variant.Vertical }, { [formItemErrorStyles]: error }) },
|
|
107
|
+
react_1.default.createElement("label", { htmlFor: `${id}_file_input`, className: (0, emotion_1.cx)({ [labelHorizontalStyles]: variant === Variant.Horizontal }, (0, emotion_1.css)({
|
|
108
|
+
textAlign: labelAlignment,
|
|
109
|
+
})) },
|
|
110
|
+
react_1.default.createElement("span", { style: { gridArea: 'label' } }, label),
|
|
111
|
+
renderDescription()),
|
|
112
|
+
react_1.default.createElement("input", { "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : 'file-input', ref: inputRef, id: `${id}_file_input`, name: id, type: "file", multiple: multi, onChange: onFilesChanged, style: { display: 'none' } }),
|
|
113
|
+
react_1.default.createElement(__1.Button, { id: id, "data-testid": "file-input-button", className: (0, emotion_1.cx)({ [buttonStyles]: true }), onClick: () => {
|
|
114
|
+
if (inputRef.current) {
|
|
115
|
+
inputRef.current.click();
|
|
116
|
+
}
|
|
117
|
+
}, title: "Select a file", leftGlyph: react_1.default.createElement(__1.Icon, { glyph: "AddFile", title: null, fill: "currentColor" }) }, buttonText)),
|
|
118
|
+
error && errorMessage && (react_1.default.createElement(__1.Label, { "data-testid": 'file-input-error', className: errorMessageStyles, htmlFor: '' }, errorMessage))));
|
|
119
|
+
}
|
|
120
|
+
exports.default = FileInput;
|
|
121
|
+
//# sourceMappingURL=file-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-input.js","sourceRoot":"","sources":["../../src/components/file-input.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gDAAwB;AACxB,oDAAiD;AACjD,oDAAkD;AAClD,kDAAgD;AAEhD,0BAA4D;AAE5D,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,kBAAQ,CAAC,GAAG,CAAC;AAE5C,MAAM,wBAAwB,GAAG,IAAA,aAAG,EAAC;IACnC,SAAS,EAAE,gBAAO,CAAC,CAAC,CAAC;IACrB,YAAY,EAAE,gBAAO,CAAC,CAAC,CAAC;IACxB,WAAW,EAAE,MAAM;IACnB,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,QAAQ;CACrB,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,IAAA,aAAG,EAAA;;CAEjC,CAAC;AAEF,MAAM,mBAAmB,GAAG,IAAA,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AAI,EAAE,IAAI,EAAC,cAAc,GAAG,IAEnE,UAAU,CACJ,CACL;QACL,KAAK,IAAI,YAAY,IAAI,CACxB,8BAAC,SAAK,mBACS,kBAAkB,EAC/B,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,EAAE,IAEV,YAAY,CACP,CACT,CACG,CACP,CAAC;AACJ,CAAC;AAED,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tooltip } from './tooltip';
|
|
3
|
+
declare const InlineDefinition: React.FunctionComponent<React.HTMLProps<HTMLSpanElement> & {
|
|
4
|
+
definition: React.ReactNode;
|
|
5
|
+
tooltipProps: Partial<Omit<React.ComponentProps<typeof Tooltip>, 'trigger' | 'children'>>;
|
|
6
|
+
}>;
|
|
7
|
+
export { InlineDefinition };
|
|
@@ -0,0 +1,31 @@
|
|
|
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.InlineDefinition = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const typography_1 = require("@leafygreen-ui/typography");
|
|
9
|
+
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
10
|
+
const tooltip_1 = require("./tooltip");
|
|
11
|
+
const merge_props_1 = require("../utils/merge-props");
|
|
12
|
+
const underline = (0, emotion_1.css)({
|
|
13
|
+
backgroundRepeat: 'repeat-x',
|
|
14
|
+
backgroundPosition: 'center bottom',
|
|
15
|
+
backgroundSize: '3px 2px',
|
|
16
|
+
backgroundImage: 'radial-gradient( circle closest-side, currentColor 75%, transparent 25%)',
|
|
17
|
+
});
|
|
18
|
+
const maxWidth = (0, emotion_1.css)({
|
|
19
|
+
maxWidth: '360px',
|
|
20
|
+
});
|
|
21
|
+
const InlineDefinition = ({ children, definition, tooltipProps, ...props }) => {
|
|
22
|
+
return (react_1.default.createElement(tooltip_1.Tooltip, { justify: "middle", spacing: 5, trigger: ({ children: tooltip, ...triggerProps }) => {
|
|
23
|
+
const merged = (0, merge_props_1.mergeProps)({ className: underline }, triggerProps, props);
|
|
24
|
+
return (react_1.default.createElement("span", { ...merged },
|
|
25
|
+
children,
|
|
26
|
+
tooltip));
|
|
27
|
+
}, ...tooltipProps },
|
|
28
|
+
react_1.default.createElement(typography_1.Body, { className: maxWidth }, definition)));
|
|
29
|
+
};
|
|
30
|
+
exports.InlineDefinition = InlineDefinition;
|
|
31
|
+
//# sourceMappingURL=inline-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-definition.js","sourceRoot":"","sources":["../../src/components/inline-definition.tsx"],"names":[],"mappings":";;;;;;AACA,kDAA0B;AAC1B,0DAAiD;AACjD,oDAA6C;AAC7C,uCAAoC;AACpC,sDAAkD;AAElD,MAAM,SAAS,GAAG,IAAA,aAAG,EAAC;IACpB,gBAAgB,EAAE,UAAU;IAC5B,kBAAkB,EAAE,eAAe;IACnC,cAAc,EAAE,SAAS;IACzB,eAAe,EACb,0EAA0E;CAC7E,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,IAAA,aAAG,EAAC;IACnB,QAAQ,EAAE,OAAO;CAClB,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAOlB,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACvD,OAAO,CACL,8BAAC,iBAAO,IACN,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,CAAC,EACV,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,YAAY,EAAE,EAAE,EAAE;YAClD,MAAM,MAAM,GAAG,IAAA,wBAAU,EACvB,EAAE,SAAS,EAAE,SAAS,EAAE,EACxB,YAAY,EACZ,KAAK,CACN,CAAC;YACF,OAAO,CACL,2CAAU,MAAM;gBACb,QAAQ;gBACR,OAAO,CACH,CACR,CAAC;QACJ,CAAC,KACG,YAAY;QAEhB,8BAAC,iBAAI,IAAC,SAAS,EAAE,QAAQ,IAAG,UAAU,CAAQ,CACtC,CACX,CAAC;AACJ,CAAC,CAAC;AAEO,4CAAgB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
export declare const Placeholder: React.FunctionComponent<Omit<React.HTMLProps<HTMLDivElement>, 'minChar' | 'maxChar' | 'width' | 'height'> & {
|
|
3
|
+
minChar?: number;
|
|
4
|
+
maxChar?: number;
|
|
5
|
+
width?: CSSProperties['width'];
|
|
6
|
+
height?: CSSProperties['height'];
|
|
7
|
+
darkMode?: boolean;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.Placeholder = void 0;
|
|
23
|
+
const react_1 = __importStar(require("react"));
|
|
24
|
+
const __1 = require("../");
|
|
25
|
+
const __2 = require("../");
|
|
26
|
+
const scale = 4;
|
|
27
|
+
const percent = (num) => (num * 100).toFixed(3) + '%';
|
|
28
|
+
const move = (0, __1.keyframes)({
|
|
29
|
+
from: {
|
|
30
|
+
backgroundPosition: `${percent(scale)} 0`,
|
|
31
|
+
},
|
|
32
|
+
to: {
|
|
33
|
+
backgroundPosition: '0 0',
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const placeholder = (0, __1.css)({
|
|
37
|
+
'--gradient-start': __2.uiColors.gray.light3,
|
|
38
|
+
'--gradient-end': 'rgba(235, 241, 239, 1)',
|
|
39
|
+
alignSelf: 'center',
|
|
40
|
+
borderRadius: 3,
|
|
41
|
+
maxWidth: '80%',
|
|
42
|
+
backgroundColor: 'var(--gradient-start)',
|
|
43
|
+
backgroundImage: `linear-gradient(
|
|
44
|
+
to right,
|
|
45
|
+
var(--gradient-start) 0%,
|
|
46
|
+
var(--gradient-end) ${percent(1 / scale / 2)},
|
|
47
|
+
var(--gradient-start) ${percent(1 / scale)},
|
|
48
|
+
var(--gradient-start) 100%
|
|
49
|
+
)`,
|
|
50
|
+
backgroundSize: `${percent(scale)} 100%`,
|
|
51
|
+
backgroundPosition: '0 0',
|
|
52
|
+
animation: `${move} ${scale}s infinite linear`,
|
|
53
|
+
});
|
|
54
|
+
const placeholderDarkMode = (0, __1.css)({
|
|
55
|
+
'--gradient-start': 'rgba(38, 55, 66, 1)',
|
|
56
|
+
'--gradient-end': 'rgba(47, 64, 74, 1)',
|
|
57
|
+
});
|
|
58
|
+
function getBoundRandom(min, max) {
|
|
59
|
+
return Math.random() * (max - min) + min;
|
|
60
|
+
}
|
|
61
|
+
const Placeholder = ({ className, minChar = 5, maxChar = 15, width: propsWidth, height: propsHeight = __2.spacing[3], darkMode, ...props }) => {
|
|
62
|
+
const width = (0, react_1.useMemo)(() => {
|
|
63
|
+
return propsWidth || `${Math.round(getBoundRandom(minChar, maxChar))}ch`;
|
|
64
|
+
}, [minChar, maxChar, propsWidth]);
|
|
65
|
+
return (react_1.default.createElement("div", { ...props, role: "presentation", "data-testid": "placeholder", className: (0, __1.cx)(placeholder, className, darkMode && placeholderDarkMode), style: { width, height: propsHeight } }));
|
|
66
|
+
};
|
|
67
|
+
exports.Placeholder = Placeholder;
|
|
68
|
+
//# sourceMappingURL=placeholder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placeholder.js","sourceRoot":"","sources":["../../src/components/placeholder.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,+CAAsD;AACtD,2BAAyC;AACzC,2BAAwC;AAGxC,MAAM,KAAK,GAAG,CAAC,CAAC;AAEhB,MAAM,OAAO,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AAEtE,MAAM,IAAI,GAAG,IAAA,aAAS,EAAC;IACrB,IAAI,EAAE;QACJ,kBAAkB,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI;KAC1C;IACD,EAAE,EAAE;QACF,kBAAkB,EAAE,KAAK;KAC1B;CACF,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,IAAA,OAAG,EAAC;IACtB,kBAAkB,EAAE,YAAQ,CAAC,IAAI,CAAC,MAAM;IACxC,gBAAgB,EAAE,wBAAwB;IAC1C,SAAS,EAAE,QAAQ;IACnB,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,KAAK;IACf,eAAe,EAAE,uBAAuB;IACxC,eAAe,EAAE;;;8BAGW,OAAO,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;gCACpB,OAAO,CAAC,CAAC,GAAG,KAAK,CAAC;;MAE5C;IACJ,cAAc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