1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | var _react = _interopRequireDefault(require("react"));
|
9 |
|
10 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
11 |
|
12 | var _withStyles = require("../helpers/withStyles");
|
13 |
|
14 | var _reactWithStyles = require("react-with-styles");
|
15 |
|
16 | var _Shimmer = _interopRequireDefault(require("./Shimmer"));
|
17 |
|
18 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19 |
|
20 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
21 |
|
22 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
23 |
|
24 | var propTypes = _objectSpread({}, _reactWithStyles.withStylesPropTypes, {
|
25 | bold: _propTypes.default.bool,
|
26 | collapsed: _propTypes.default.bool,
|
27 | disabled: _propTypes.default.bool,
|
28 | error: _propTypes.default.bool,
|
29 | inline: _propTypes.default.bool,
|
30 | inverse: _propTypes.default.bool,
|
31 | loading: _propTypes.default.bool,
|
32 | large: _propTypes.default.bool,
|
33 | light: _propTypes.default.bool,
|
34 | micro: _propTypes.default.bool,
|
35 | muted: _propTypes.default.bool,
|
36 | small: _propTypes.default.bool,
|
37 | short: _propTypes.default.bool,
|
38 | shimmerHeight: _propTypes.default.string,
|
39 | shimmerWidth: _propTypes.default.string,
|
40 | children: _propTypes.default.any
|
41 | });
|
42 |
|
43 | var Text = function Text(_ref) {
|
44 | var children = _ref.children,
|
45 | collapsed = _ref.collapsed,
|
46 | bold = _ref.bold,
|
47 | disabled = _ref.disabled,
|
48 | error = _ref.error,
|
49 | inline = _ref.inline,
|
50 | inverse = _ref.inverse,
|
51 | loading = _ref.loading,
|
52 | large = _ref.large,
|
53 | light = _ref.light,
|
54 | micro = _ref.micro,
|
55 | muted = _ref.muted,
|
56 | short = _ref.short,
|
57 | shimmerHeight = _ref.shimmerHeight,
|
58 | shimmerWidth = _ref.shimmerWidth,
|
59 | small = _ref.small,
|
60 | styles = _ref.styles;
|
61 |
|
62 | if (small) {
|
63 | return _react.default.createElement("small", (0, _withStyles.css)(styles.text, bold && styles.text_bold, collapsed && styles.text_collapsed, disabled && styles.text_disabled, error && styles.text_error, inverse && styles.text_inverse, large && styles.text_large, light && styles.text_light, micro && styles.text_micro, muted && styles.text_muted, short && styles.text_short, small && styles.text_small, inline && styles.text_inline), loading ? _react.default.createElement(_Shimmer.default, {
|
64 | height: shimmerHeight || '1ex',
|
65 | width: shimmerWidth || '60%'
|
66 | }) : children);
|
67 | } else if (inline) {
|
68 | return _react.default.createElement("span", (0, _withStyles.css)(styles.text, !loading && styles.text_inline, bold && styles.text_bold, collapsed && styles.text_collapsed, error && styles.text_error, disabled && styles.text_disabled, inverse && styles.text_inverse, large && styles.text_large, light && styles.text_light, micro && styles.text_micro, muted && styles.text_muted, short && styles.text_short, small && styles.text_small), loading ? _react.default.createElement(_Shimmer.default, {
|
69 | height: shimmerHeight || '1ex',
|
70 | width: shimmerWidth || '60%'
|
71 | }) : children);
|
72 | }
|
73 |
|
74 | return _react.default.createElement("p", (0, _withStyles.css)(styles.text, bold && styles.text_bold, collapsed && styles.text_collapsed, disabled && styles.text_disabled, error && styles.text_error, inverse && styles.text_inverse, large && styles.text_large, light && styles.text_light, micro && styles.text_micro, muted && styles.text_muted, short && styles.text_short, small && styles.text_small, inline && styles.text_inline), loading ? _react.default.createElement(_Shimmer.default, {
|
75 | height: "1ex",
|
76 | width: "60%"
|
77 | }) : children);
|
78 | };
|
79 |
|
80 | Text.propTypes = propTypes;
|
81 | var TextWithStyles = (0, _withStyles.withStyles)(function (_ref2) {
|
82 | var units = _ref2.units,
|
83 | color = _ref2.color,
|
84 | weight = _ref2.weight,
|
85 | fontSize = _ref2.fontSize,
|
86 | lineHeight = _ref2.lineHeight,
|
87 | font = _ref2.font,
|
88 | breakpoint = _ref2.breakpoint;
|
89 | return {
|
90 | text: _defineProperty({
|
91 | wordWrap: 'break-word',
|
92 | letterSpacing: 'normal',
|
93 | fontFamily: font.default,
|
94 | color: color.grayDarker,
|
95 | fontWeight: weight.normal,
|
96 | fontSize: fontSize.small.regular,
|
97 | lineHeight: lineHeight.regular,
|
98 | margin: 0,
|
99 | padding: 0,
|
100 | display: 'block'
|
101 | }, breakpoint.large, {
|
102 | fontSize: fontSize.large.regular
|
103 | }),
|
104 | text_bold: {
|
105 | fontWeight: weight.bold
|
106 | },
|
107 | text_collapsed: {
|
108 | whiteSpace: 'nowrap',
|
109 | overflow: 'hidden',
|
110 | textOverflow: 'ellipsis'
|
111 | },
|
112 | text_disabled: {
|
113 | opacity: .5
|
114 | },
|
115 | text_error: {
|
116 | color: color.alertDark
|
117 | },
|
118 | text_inverse: {
|
119 | color: color.white
|
120 | },
|
121 | text_large: _defineProperty({
|
122 | fontSize: fontSize.small.large
|
123 | }, breakpoint.large, {
|
124 | fontSize: fontSize.large.large
|
125 | }),
|
126 | text_light: {
|
127 | fontWeight: weight.light
|
128 | },
|
129 | text_micro: _defineProperty({
|
130 | fontSize: fontSize.small.micro
|
131 | }, breakpoint.large, {
|
132 | fontSize: fontSize.large.micro
|
133 | }),
|
134 | text_muted: {
|
135 | color: color.blueGrayDark
|
136 | },
|
137 | text_short: {
|
138 | lineHeight: lineHeight.short
|
139 | },
|
140 | text_small: _defineProperty({
|
141 | fontSize: fontSize.small.small
|
142 | }, breakpoint.large, {
|
143 | fontSize: fontSize.large.small
|
144 | }),
|
145 | text_inline: {
|
146 | display: 'inline-block'
|
147 | }
|
148 | };
|
149 | })(Text);
|
150 | var _default = TextWithStyles;
|
151 | exports.default = _default; |
\ | No newline at end of file |