@widergy/energy-ui 1.134.2 → 2.0.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/CHANGELOG.md +12 -0
- package/dist/components/Loading/index.js +1 -2
- package/dist/components/Loading/styles.module.scss +1 -1
- package/dist/components/Loading/theme.js +2 -1
- package/dist/components/UTAlert/theme.js +3 -2
- package/dist/components/UTAttachment/layout.js +9 -7
- package/dist/components/UTAttachment/styles.module.scss +0 -1
- package/dist/components/UTAttachment/theme.js +2 -1
- package/dist/components/UTAutocomplete/theme.js +8 -6
- package/dist/components/UTAvatar/index.js +21 -8
- package/dist/components/UTBarChart/components/Legend/index.js +24 -20
- package/dist/components/UTBarChart/components/Pagination/index.js +26 -20
- package/dist/components/UTBarChart/components/YAxis/AxisElement/index.js +1 -1
- package/dist/components/UTBarChart/components/YAxis/index.js +1 -1
- package/dist/components/UTBarChart/index.js +7 -4
- package/dist/components/UTBarChart/theme.js +10 -7
- package/dist/components/UTBarChart/types.js +2 -2
- package/dist/components/UTBreadcrumbs/index.js +14 -8
- package/dist/components/UTBreadcrumbs/styles.module.scss +0 -6
- package/dist/components/UTBreadcrumbs/theme.js +2 -13
- package/dist/components/UTButton/README.md +35 -0
- package/dist/components/UTButton/constants.js +42 -0
- package/dist/components/UTButton/index.js +63 -83
- package/dist/components/UTButton/styles.module.scss +36 -0
- package/dist/components/UTButton/theme.js +143 -158
- package/dist/components/UTCBUInput/theme.js +2 -1
- package/dist/components/UTCard/components/UTCardFooter/index.js +5 -6
- package/dist/components/UTCard/index.js +23 -29
- package/dist/components/UTCard/theme.js +2 -1
- package/dist/components/UTCarousel/components/Button/index.js +1 -1
- package/dist/components/UTCarousel/components/Legend/index.js +1 -4
- package/dist/components/UTCarousel/components/Slider/component/Slide/index.js +2 -5
- package/dist/components/UTCarousel/components/Slider/index.js +45 -18
- package/dist/components/UTCarousel/components/Slider/layout.js +13 -12
- package/dist/components/UTCarousel/theme.js +2 -1
- package/dist/components/UTCheckList/index.js +11 -9
- package/dist/components/UTCheckList/theme.js +8 -3
- package/dist/components/UTCheckbox/index.js +34 -28
- package/dist/components/UTCheckbox/theme.js +11 -3
- package/dist/components/UTConsumptionBar/components/ConsumptionBarIndicator/index.js +7 -8
- package/dist/components/UTConsumptionBar/components/ConsumptionBarIndicator/styles.module.scss +1 -2
- package/dist/components/UTConsumptionBar/index.js +22 -13
- package/dist/components/UTConsumptionBar/styles.module.scss +0 -14
- package/dist/components/UTCuit/index.js +2 -2
- package/dist/components/UTCuit/theme.js +1 -1
- package/dist/components/UTDatePicker/index.js +29 -27
- package/dist/components/UTDatePicker/theme.js +22 -7
- package/dist/components/UTDialog/index.js +19 -23
- package/dist/components/UTDialog/theme.js +8 -23
- package/dist/components/UTDialog/types.js +5 -6
- package/dist/components/UTDotMenu/index.js +16 -8
- package/dist/components/UTEmojiPicker/theme.js +2 -1
- package/dist/components/UTFileInput/layout.js +5 -4
- package/dist/components/UTFileInput/styles.module.scss +0 -1
- package/dist/components/UTIconButton/theme.js +2 -1
- package/dist/components/UTImageRadio/components/ImageRadioCard/index.js +2 -2
- package/dist/components/UTImageRadio/index.js +2 -1
- package/dist/components/UTImageRadio/theme.js +15 -12
- package/dist/components/UTLabel/README.md +169 -0
- package/dist/components/UTLabel/constants.js +91 -0
- package/dist/components/UTLabel/index.js +41 -104
- package/dist/components/UTLabel/theme.js +29 -84
- package/dist/components/UTMap/index.js +7 -7
- package/dist/components/UTMap/styles.module.scss +0 -5
- package/dist/components/UTMenu/theme.js +3 -2
- package/dist/components/UTPanel/index.js +11 -10
- package/dist/components/UTPasswordField/components/PasswordValidations/components/Error/index.js +4 -3
- package/dist/components/UTPasswordField/components/PasswordValidations/components/Error/styles.module.scss +2 -2
- package/dist/components/UTPasswordField/components/PasswordValidations/components/Validation/index.js +16 -16
- package/dist/components/UTPasswordField/components/PasswordValidations/components/Validation/styles.module.scss +2 -2
- package/dist/components/UTPasswordField/components/PasswordValidations/index.js +11 -9
- package/dist/components/UTPasswordField/components/PasswordWarning/index.js +3 -3
- package/dist/components/UTPasswordField/components/PasswordWarning/styles.module.scss +1 -1
- package/dist/components/UTPasswordField/theme.js +13 -27
- package/dist/components/UTPhoneInput/index.js +4 -4
- package/dist/components/UTPhoneInput/theme.js +3 -6
- package/dist/components/UTPieChart/theme.js +2 -1
- package/dist/components/UTProgressBar/index.js +27 -20
- package/dist/components/UTProgressBar/theme.js +14 -13
- package/dist/components/UTRadioGroup/index.js +35 -22
- package/dist/components/UTRadioGroup/theme.js +10 -6
- package/dist/components/UTRating/components/Star/index.js +2 -1
- package/dist/components/UTRating/index.js +3 -1
- package/dist/components/UTRating/theme.js +3 -2
- package/dist/components/UTSelect/index.js +13 -3
- package/dist/components/UTSelect/styles.module.scss +5 -0
- package/dist/components/UTSelect/theme.js +7 -2
- package/dist/components/UTSidebar/theme.js +6 -5
- package/dist/components/UTSkeleton/index.js +3 -2
- package/dist/components/UTSwitch/index.js +2 -1
- package/dist/components/UTSwitch/theme.js +2 -1
- package/dist/components/UTTable/components/TableHeader/index.js +11 -7
- package/dist/components/UTTable/theme.js +31 -29
- package/dist/components/UTTabs/index.js +25 -20
- package/dist/components/UTTabs/theme.js +2 -1
- package/dist/components/UTTextArea/index.js +2 -1
- package/dist/components/UTTextArea/theme.js +2 -1
- package/dist/components/UTTextInput/index.js +16 -8
- package/dist/components/UTTextInput/styles.module.scss +3 -2
- package/dist/components/UTTextInput/theme.js +3 -2
- package/dist/components/UTToggle/components/ToggleOption/index.js +1 -0
- package/dist/components/UTToggle/theme.js +2 -1
- package/dist/components/UTTooltip/index.js +6 -4
- package/dist/components/UTTooltip/styles.module.scss +4 -2
- package/dist/components/UTTooltip/theme.js +2 -1
- package/dist/components/UTWorkflowContainer/components/ActionButton/index.js +12 -4
- package/dist/components/UTWorkflowContainer/index.js +19 -15
- package/dist/components/UTWorkflowContainer/styles.module.scss +0 -34
- package/dist/components/UTWorkflowContainer/theme.js +12 -58
- package/dist/components/UTWorkflowContainer/types.js +1 -1
- package/dist/components/WithTheme/layout.js +46 -42
- package/dist/scss/variables/_colors.scss +8 -0
- package/dist/theme.js +4 -1
- package/dist/types/formTypes.js +3 -3
- package/dist/utils/classesUtils.js +7 -3
- package/dist/utils/shadowUtils.js +40 -0
- package/package.json +5 -3
- package/dist/components/UTDialog/components/ActionButton/index.js +0 -35
- package/dist/components/UTLabel/styles.module.scss +0 -3
|
@@ -64,8 +64,8 @@ var ImageRadioCard = function ImageRadioCard(_ref) {
|
|
|
64
64
|
}, /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
65
65
|
className: "".concat(classes.name, " ").concat(_stylesModule.default.text, " ").concat(isSelected && !transparent && classes.selectedText)
|
|
66
66
|
}, name), description && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
67
|
-
|
|
68
|
-
className: "".concat(classes.description, " ").concat(_stylesModule.default.text, " ").concat(isSelected &&
|
|
67
|
+
weight: "light",
|
|
68
|
+
className: "".concat(classes.description, " ").concat(_stylesModule.default.text, " ").concat(isSelected && _stylesModule.default.selectedText)
|
|
69
69
|
}, description)));
|
|
70
70
|
};
|
|
71
71
|
return tooltip ? /*#__PURE__*/_react.default.createElement(_UTTooltip.default, {
|
|
@@ -67,8 +67,9 @@ var UTImageRadio = function UTImageRadio(_ref) {
|
|
|
67
67
|
classes: classes
|
|
68
68
|
});
|
|
69
69
|
})), meta && (0, _form.shouldShowErrors)(meta) && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
70
|
+
colorTheme: "error",
|
|
70
71
|
className: _stylesModule.default.error,
|
|
71
|
-
|
|
72
|
+
variant: "small"
|
|
72
73
|
}, meta.error));
|
|
73
74
|
};
|
|
74
75
|
UTImageRadio.propTypes = {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.retrieveStyle = void 0;
|
|
7
7
|
var _seamlessImmutable = require("seamless-immutable");
|
|
8
8
|
var _colors = _interopRequireDefault(require("../../scss/variables/_colors.scss"));
|
|
9
|
+
var _classesUtils = require("../../utils/classesUtils");
|
|
9
10
|
var _constants = require("./constants");
|
|
10
11
|
var _utils = require("./utils");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -13,7 +14,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
13
14
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
15
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
16
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
-
var retrieveStyle = function retrieveStyle(
|
|
17
|
+
var retrieveStyle = function retrieveStyle(_ref) {
|
|
18
|
+
var _theme$UTImageRadio, _theme$UTImageRadio$c, _theme$UTImageRadio2, _theme$UTImageRadio2$, _theme$UTImageRadio3, _theme$UTImageRadio3$, _theme$UTImageRadio4, _theme$UTImageRadio4$, _theme$UTImageRadio5, _theme$UTImageRadio5$, _theme$UTImageRadio6, _theme$UTImageRadio6$, _theme$UTImageRadio7, _theme$UTImageRadio7$, _theme$UTImageRadio8, _theme$UTImageRadio8$, _theme$UTImageRadio9, _theme$UTImageRadio9$, _theme$UTImageRadio10, _theme$UTImageRadio11, _theme$UTImageRadio12, _theme$UTImageRadio13;
|
|
19
|
+
var theme = _ref.theme;
|
|
17
20
|
var tabletMobile = (0, _seamlessImmutable.getIn)(theme, ['Media', 'tabletMobile']);
|
|
18
21
|
return {
|
|
19
22
|
containerCard: {
|
|
@@ -33,7 +36,7 @@ var retrieveStyle = function retrieveStyle(theme) {
|
|
|
33
36
|
pointerEvents: (0, _seamlessImmutable.getIn)(theme, ['UTImageRadio', 'isSelected', 'pointerEvents'], 'none')
|
|
34
37
|
},
|
|
35
38
|
containerText: _defineProperty({
|
|
36
|
-
width: (0,
|
|
39
|
+
width: (0, _classesUtils.withImportant)((theme === null || theme === void 0 ? void 0 : (_theme$UTImageRadio = theme.UTImageRadio) === null || _theme$UTImageRadio === void 0 ? void 0 : (_theme$UTImageRadio$c = _theme$UTImageRadio.containerText) === null || _theme$UTImageRadio$c === void 0 ? void 0 : _theme$UTImageRadio$c.width) || '100%')
|
|
37
40
|
}, tabletMobile, {
|
|
38
41
|
width: '100%'
|
|
39
42
|
}),
|
|
@@ -44,27 +47,27 @@ var retrieveStyle = function retrieveStyle(theme) {
|
|
|
44
47
|
vertical: {
|
|
45
48
|
flexDirection: (0, _seamlessImmutable.getIn)(theme, ['UTImageRadio', 'vertical', 'flexDirection'], 'column'),
|
|
46
49
|
border: (0, _seamlessImmutable.getIn)(theme, ['UTImageRadio', 'vertical', 'border'], '2px solid transparent'),
|
|
47
|
-
borderWidth: (0,
|
|
50
|
+
borderWidth: (0, _classesUtils.withImportant)((theme === null || theme === void 0 ? void 0 : (_theme$UTImageRadio2 = theme.UTImageRadio) === null || _theme$UTImageRadio2 === void 0 ? void 0 : (_theme$UTImageRadio2$ = _theme$UTImageRadio2.vertical) === null || _theme$UTImageRadio2$ === void 0 ? void 0 : _theme$UTImageRadio2$.borderWidth) || '2px'),
|
|
48
51
|
alignItems: (0, _seamlessImmutable.getIn)(theme, ['UTImageRadio', 'vertical', 'alignItems'], 'center'),
|
|
49
52
|
textAlign: (0, _seamlessImmutable.getIn)(theme, ['UTImageRadio', 'vertical', 'textAlign'], 'center'),
|
|
50
|
-
width: (0,
|
|
53
|
+
width: (0, _classesUtils.withImportant)((theme === null || theme === void 0 ? void 0 : (_theme$UTImageRadio3 = theme.UTImageRadio) === null || _theme$UTImageRadio3 === void 0 ? void 0 : (_theme$UTImageRadio3$ = _theme$UTImageRadio3.vertical) === null || _theme$UTImageRadio3$ === void 0 ? void 0 : _theme$UTImageRadio3$.width) || 'fit-content'),
|
|
51
54
|
pointerEvents: (0, _seamlessImmutable.getIn)(theme, ['UTImageRadio', 'vertical', 'pointerEvents'], 'auto'),
|
|
52
55
|
'&:hover': {
|
|
53
|
-
border: (0,
|
|
56
|
+
border: (0, _classesUtils.withImportant)((theme === null || theme === void 0 ? void 0 : (_theme$UTImageRadio4 = theme.UTImageRadio) === null || _theme$UTImageRadio4 === void 0 ? void 0 : (_theme$UTImageRadio4$ = _theme$UTImageRadio4.vertical) === null || _theme$UTImageRadio4$ === void 0 ? void 0 : _theme$UTImageRadio4$.border) || "2px solid ".concat(_colors.default.imageRadioBackground))
|
|
54
57
|
}
|
|
55
58
|
},
|
|
56
59
|
description: {
|
|
57
|
-
color:
|
|
58
|
-
fontSize: "".concat((0
|
|
59
|
-
fontWeight:
|
|
60
|
+
color: (0, _classesUtils.withImportant)((theme === null || theme === void 0 ? void 0 : (_theme$UTImageRadio5 = theme.UTImageRadio) === null || _theme$UTImageRadio5 === void 0 ? void 0 : (_theme$UTImageRadio5$ = _theme$UTImageRadio5.description) === null || _theme$UTImageRadio5$ === void 0 ? void 0 : _theme$UTImageRadio5$.color) || _colors.default.black),
|
|
61
|
+
fontSize: (0, _classesUtils.withImportant)("".concat((theme === null || theme === void 0 ? void 0 : (_theme$UTImageRadio6 = theme.UTImageRadio) === null || _theme$UTImageRadio6 === void 0 ? void 0 : (_theme$UTImageRadio6$ = _theme$UTImageRadio6.description) === null || _theme$UTImageRadio6$ === void 0 ? void 0 : _theme$UTImageRadio6$.fontSize) || 14, "px")),
|
|
62
|
+
fontWeight: (0, _classesUtils.withImportant)((theme === null || theme === void 0 ? void 0 : (_theme$UTImageRadio7 = theme.UTImageRadio) === null || _theme$UTImageRadio7 === void 0 ? void 0 : (_theme$UTImageRadio7$ = _theme$UTImageRadio7.description) === null || _theme$UTImageRadio7$ === void 0 ? void 0 : _theme$UTImageRadio7$.fontWeight) || 400)
|
|
60
63
|
},
|
|
61
64
|
name: {
|
|
62
|
-
color:
|
|
63
|
-
fontSize: "".concat((0
|
|
64
|
-
fontWeight:
|
|
65
|
+
color: (0, _classesUtils.withImportant)((theme === null || theme === void 0 ? void 0 : (_theme$UTImageRadio8 = theme.UTImageRadio) === null || _theme$UTImageRadio8 === void 0 ? void 0 : (_theme$UTImageRadio8$ = _theme$UTImageRadio8.name) === null || _theme$UTImageRadio8$ === void 0 ? void 0 : _theme$UTImageRadio8$.color) || _colors.default.black),
|
|
66
|
+
fontSize: (0, _classesUtils.withImportant)("".concat((theme === null || theme === void 0 ? void 0 : (_theme$UTImageRadio9 = theme.UTImageRadio) === null || _theme$UTImageRadio9 === void 0 ? void 0 : (_theme$UTImageRadio9$ = _theme$UTImageRadio9.name) === null || _theme$UTImageRadio9$ === void 0 ? void 0 : _theme$UTImageRadio9$.fontSize) || 18, "px")),
|
|
67
|
+
fontWeight: (0, _classesUtils.withImportant)((theme === null || theme === void 0 ? void 0 : (_theme$UTImageRadio10 = theme.UTImageRadio) === null || _theme$UTImageRadio10 === void 0 ? void 0 : (_theme$UTImageRadio11 = _theme$UTImageRadio10.name) === null || _theme$UTImageRadio11 === void 0 ? void 0 : _theme$UTImageRadio11.fontWeight) || 600)
|
|
65
68
|
},
|
|
66
69
|
selectedText: {
|
|
67
|
-
color:
|
|
70
|
+
color: (0, _classesUtils.withImportant)((theme === null || theme === void 0 ? void 0 : (_theme$UTImageRadio12 = theme.UTImageRadio) === null || _theme$UTImageRadio12 === void 0 ? void 0 : (_theme$UTImageRadio13 = _theme$UTImageRadio12.selectedText) === null || _theme$UTImageRadio13 === void 0 ? void 0 : _theme$UTImageRadio13.color) || _colors.default.white)
|
|
68
71
|
}
|
|
69
72
|
};
|
|
70
73
|
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# UTLabel
|
|
2
|
+
|
|
3
|
+
Component used for displaying text values and markdown.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
| Name | Type | Default | Description |
|
|
8
|
+
| ----------------- | ------ | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| className | string | | Additional classes. |
|
|
10
|
+
| classes | string | | Classes returned by UTLabel's own [theme](./theme.js#L40) `retrieveStyle`. |
|
|
11
|
+
| colorTheme | string | 'primary' | Color theme to style the UTLabel. Has to be defined in the proyect theme. [Example](#colortheme). |
|
|
12
|
+
| markdownRenderers | object | [MARKDOWN_RENDERERS](./constants.js#L36) | ⚠️ Requires `withMarkdown` to be set to `true` <br />Object mapping tag names to React components. The keys in components are HTML equivalents for the things you write with markdown [List of tags](#markdown-renderers). |
|
|
13
|
+
| title | string | | [Title global attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title). |
|
|
14
|
+
| variant | string | 'body' | Defines html component to use. For a list of available variants, check [here](#variants). Font sizes can be overwritten (⚠️ for the entire proyect) through the proyect's theme. |
|
|
15
|
+
| weight | string | 'regular' | Defines font-weight to be used. For a list of available options, check [here](#font-weights). |
|
|
16
|
+
| withMarkdown | bool | false | Tells the component whether or not to render text inside as markdown. |
|
|
17
|
+
|
|
18
|
+
## Examples
|
|
19
|
+
|
|
20
|
+
### colorTheme
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
UTLabel: {
|
|
24
|
+
colorThemes: {
|
|
25
|
+
primary: {
|
|
26
|
+
color: Colors.primary
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Use
|
|
33
|
+
|
|
34
|
+
```JSX
|
|
35
|
+
<UTLabel colorTheme='primary'>Your text here</UTLabel>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Markdown renderers
|
|
39
|
+
|
|
40
|
+
| markdown | component |
|
|
41
|
+
| ------------------------- | --------------------------------------- |
|
|
42
|
+
| `blockquote` | `blockquote` |
|
|
43
|
+
| `break` | `br` |
|
|
44
|
+
| `code`, `inlineCode` | `code`, `pre`**\*** |
|
|
45
|
+
| `definition` | **†** |
|
|
46
|
+
| `emphasis` | `em` |
|
|
47
|
+
| `heading` | `h1`, `h2`, `h3`, `h4`, `h5`, `h6`**§** |
|
|
48
|
+
| `image`, `imageReference` | `img`**†** |
|
|
49
|
+
| `link`, `linkReference` | `a`**†** |
|
|
50
|
+
| `list` | `ol`, `ul`**¶** |
|
|
51
|
+
| `listItem` | `li` |
|
|
52
|
+
| `paragraph` | `p` |
|
|
53
|
+
| `strong` | `strong` |
|
|
54
|
+
| `text` | |
|
|
55
|
+
| `thematicBreak` | `hr` |
|
|
56
|
+
|
|
57
|
+
- **\*** It’s possible to differentiate between code based on the `inline`
|
|
58
|
+
prop.
|
|
59
|
+
Block code is also wrapped in a `pre`
|
|
60
|
+
- **†** Resource (`[text](url)`) and reference (`[text][id]`) style links and
|
|
61
|
+
images (and their definitions) are now resolved and treated the same
|
|
62
|
+
- **§** It’s possible to differentiate between heading based on the `level`
|
|
63
|
+
prop
|
|
64
|
+
- **¶** It’s possible to differentiate between lists based on the `ordered`
|
|
65
|
+
prop
|
|
66
|
+
|
|
67
|
+
Example
|
|
68
|
+
|
|
69
|
+
```JSX
|
|
70
|
+
const markdownRenderers = {
|
|
71
|
+
a: ({ href, children }) => ( <a href={href}>{children}</a> );
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
<UTLabel withMarkdown markdownRenderers={markdownRenderers}>
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
<details>
|
|
79
|
+
<summary>Show list of props for each component</summary>
|
|
80
|
+
The keys in components are HTML equivalents for the things you write with
|
|
81
|
+
markdown (such as `h1` for `# heading`)**†**
|
|
82
|
+
|
|
83
|
+
**†** Normally, in markdown, those are: `a`, `blockquote`, `code`, `em`, `h1`,
|
|
84
|
+
`h2`, `h3`, `h4`, `h5`, `h6`, `hr`, `img`, `li`, `ol`, `p`, `pre`, `strong`, and
|
|
85
|
+
`ul`.
|
|
86
|
+
|
|
87
|
+
The props that are passed are what you probably would expect: an `a` (link) will
|
|
88
|
+
get `href` (and `title`) props, and `img` (image) an `src` (and `title`), etc.
|
|
89
|
+
There are some extra props passed.
|
|
90
|
+
|
|
91
|
+
- `code`
|
|
92
|
+
- `inline` (`boolean?`)
|
|
93
|
+
— set to `true` for inline code
|
|
94
|
+
- `className` (`string?`)
|
|
95
|
+
— set to `language-js` or so when using ` ```js `
|
|
96
|
+
- `h1`, `h2`, `h3`, `h4`, `h5`, `h6`
|
|
97
|
+
- `level` (`number` beween 1 and 6)
|
|
98
|
+
— heading rank
|
|
99
|
+
- `input` (when using [`remark-gfm`][gfm])
|
|
100
|
+
- `checked` (`boolean`)
|
|
101
|
+
— whether the item is checked
|
|
102
|
+
- `disabled` (`true`)
|
|
103
|
+
- `type` (`'checkbox'`)
|
|
104
|
+
- `li`
|
|
105
|
+
- `index` (`number`)
|
|
106
|
+
— number of preceding items (so first gets `0`, etc.)
|
|
107
|
+
- `ordered` (`boolean`)
|
|
108
|
+
— whether the parent is an `ol` or not
|
|
109
|
+
- `checked` (`boolean?`)
|
|
110
|
+
— `null` normally, `boolean` when using [`remark-gfm`][gfm]’s tasklists
|
|
111
|
+
- `className` (`string?`)
|
|
112
|
+
— set to `task-list-item` when using [`remark-gfm`][gfm] and the
|
|
113
|
+
item1 is a tasklist
|
|
114
|
+
- `ol`, `ul`
|
|
115
|
+
- `depth` (`number`)
|
|
116
|
+
— number of ancestral lists (so first gets `0`, etc.)
|
|
117
|
+
- `ordered` (`boolean`)
|
|
118
|
+
— whether it’s an `ol` or not
|
|
119
|
+
- `className` (`string?`)
|
|
120
|
+
— set to `contains-task-list` when using [`remark-gfm`][gfm] and the
|
|
121
|
+
list contains one or more tasklists
|
|
122
|
+
- `td`, `th` (when using [`remark-gfm`][gfm])
|
|
123
|
+
- `style` (`Object?`)
|
|
124
|
+
— something like `{textAlign: 'left'}` depending on how the cell is
|
|
125
|
+
aligned
|
|
126
|
+
- `isHeader` (`boolean`)
|
|
127
|
+
— whether it’s a `th` or not
|
|
128
|
+
- `tr` (when using [`remark-gfm`][gfm])
|
|
129
|
+
- `isHeader` (`boolean`)
|
|
130
|
+
— whether it’s in the `thead` or not
|
|
131
|
+
|
|
132
|
+
Every component will receive a `node` (`Object`).
|
|
133
|
+
This is the original [hast](https://github.com/syntax-tree/hast) element being
|
|
134
|
+
turned into a React element.
|
|
135
|
+
|
|
136
|
+
Every element will receive a `key` (`string`).
|
|
137
|
+
See [React’s docs](https://reactjs.org/docs/lists-and-keys.html#keys) for more
|
|
138
|
+
info.
|
|
139
|
+
|
|
140
|
+
</details>
|
|
141
|
+
|
|
142
|
+
### variants
|
|
143
|
+
|
|
144
|
+
| Variant | Component | Default font size |
|
|
145
|
+
| --------- | --------- | ----------------- |
|
|
146
|
+
| title1 | h1 | 30px |
|
|
147
|
+
| title2 | h2 | 24px |
|
|
148
|
+
| title3 | h3 | 22px |
|
|
149
|
+
| subtitle1 | h4 | 18px |
|
|
150
|
+
| subtitle2 | h5 | 16px |
|
|
151
|
+
| body | span | 16px |
|
|
152
|
+
| small | span | 14px |
|
|
153
|
+
| xsmall | span | 13px |
|
|
154
|
+
| th | th | 16px |
|
|
155
|
+
| td | td | 16px |
|
|
156
|
+
|
|
157
|
+
### font-weights
|
|
158
|
+
|
|
159
|
+
| Name | Weight |
|
|
160
|
+
| ---------- | ------ |
|
|
161
|
+
| thin | 100 |
|
|
162
|
+
| extralight | 200 |
|
|
163
|
+
| light | 300 |
|
|
164
|
+
| regular | 400 |
|
|
165
|
+
| medium | 500 |
|
|
166
|
+
| semibold | 600 |
|
|
167
|
+
| bold | 700 |
|
|
168
|
+
| extrabold | 800 |
|
|
169
|
+
| black | 900 |
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WEIGHTS = exports.VARIANTS_SIZES = exports.VARIANTS_LINE_HEIGHT = exports.VARIANTS = exports.MARKDOWN_RENDERERS = exports.DEFAULT_PROPS = exports.COLOR_THEMES = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
/* eslint-disable react/prop-types */
|
|
10
|
+
|
|
11
|
+
var VARIANTS = {
|
|
12
|
+
title1: 'h1',
|
|
13
|
+
title2: 'h2',
|
|
14
|
+
title3: 'h3',
|
|
15
|
+
subtitle1: 'h4',
|
|
16
|
+
subtitle2: 'h5',
|
|
17
|
+
body: 'div',
|
|
18
|
+
small: 'div',
|
|
19
|
+
xsmall: 'div',
|
|
20
|
+
th: 'th',
|
|
21
|
+
td: 'td'
|
|
22
|
+
};
|
|
23
|
+
exports.VARIANTS = VARIANTS;
|
|
24
|
+
var VARIANTS_SIZES = {
|
|
25
|
+
title1: '1.875rem',
|
|
26
|
+
title2: '1.5rem',
|
|
27
|
+
title3: '1.375rem',
|
|
28
|
+
subtitle1: '1.125rem',
|
|
29
|
+
subtitle2: '1rem',
|
|
30
|
+
body: '1rem',
|
|
31
|
+
small: '0.875rem',
|
|
32
|
+
xsmall: '0.813rem',
|
|
33
|
+
th: '1rem',
|
|
34
|
+
td: '1rem'
|
|
35
|
+
};
|
|
36
|
+
exports.VARIANTS_SIZES = VARIANTS_SIZES;
|
|
37
|
+
var VARIANTS_LINE_HEIGHT = {
|
|
38
|
+
title1: '100%',
|
|
39
|
+
title2: '100%',
|
|
40
|
+
title3: '100%',
|
|
41
|
+
subtitle1: '100%',
|
|
42
|
+
subtitle2: '100%',
|
|
43
|
+
body: '1.375rem',
|
|
44
|
+
small: '1.375rem',
|
|
45
|
+
xsmall: '1.25rem',
|
|
46
|
+
th: '1.375rem',
|
|
47
|
+
td: '1.375rem'
|
|
48
|
+
};
|
|
49
|
+
exports.VARIANTS_LINE_HEIGHT = VARIANTS_LINE_HEIGHT;
|
|
50
|
+
var WEIGHTS = {
|
|
51
|
+
thin: 100,
|
|
52
|
+
extralight: 200,
|
|
53
|
+
light: 300,
|
|
54
|
+
regular: 400,
|
|
55
|
+
medium: 500,
|
|
56
|
+
semibold: 600,
|
|
57
|
+
bold: 700,
|
|
58
|
+
extrabold: 800,
|
|
59
|
+
black: 900
|
|
60
|
+
};
|
|
61
|
+
exports.WEIGHTS = WEIGHTS;
|
|
62
|
+
var COLOR_THEMES = {
|
|
63
|
+
dark: 'dark',
|
|
64
|
+
gray: 'gray',
|
|
65
|
+
light: 'light',
|
|
66
|
+
success: 'success',
|
|
67
|
+
error: 'error',
|
|
68
|
+
warning: 'warning',
|
|
69
|
+
information: 'information'
|
|
70
|
+
};
|
|
71
|
+
exports.COLOR_THEMES = COLOR_THEMES;
|
|
72
|
+
var MARKDOWN_RENDERERS = {
|
|
73
|
+
a: function a(_ref) {
|
|
74
|
+
var href = _ref.href,
|
|
75
|
+
children = _ref.children;
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement("a", {
|
|
77
|
+
href: href,
|
|
78
|
+
rel: "noopener noreferrer",
|
|
79
|
+
target: "_blank"
|
|
80
|
+
}, children);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
exports.MARKDOWN_RENDERERS = MARKDOWN_RENDERERS;
|
|
84
|
+
var DEFAULT_PROPS = {
|
|
85
|
+
colorTheme: 'dark',
|
|
86
|
+
markdownRenderers: MARKDOWN_RENDERERS,
|
|
87
|
+
variant: 'body',
|
|
88
|
+
weight: 'regular',
|
|
89
|
+
withMarkdown: false
|
|
90
|
+
};
|
|
91
|
+
exports.DEFAULT_PROPS = DEFAULT_PROPS;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -8,121 +9,57 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
9
|
var _propTypes = require("prop-types");
|
|
9
10
|
var _reactMarkdown = _interopRequireDefault(require("react-markdown"));
|
|
10
11
|
var _remarkBreaks = _interopRequireDefault(require("remark-breaks"));
|
|
11
|
-
var
|
|
12
|
-
var _UTSkeleton = _interopRequireDefault(require("../UTSkeleton"));
|
|
12
|
+
var _rehypeRaw = _interopRequireDefault(require("rehype-raw"));
|
|
13
13
|
var _WithTheme = _interopRequireDefault(require("../WithTheme"));
|
|
14
|
+
var _classesUtils = require("../../utils/classesUtils");
|
|
15
|
+
var _UTSkeleton = _interopRequireDefault(require("../UTSkeleton"));
|
|
16
|
+
var _constants = require("./constants");
|
|
14
17
|
var _theme = require("./theme");
|
|
15
|
-
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
22
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
23
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
24
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
26
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
27
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
28
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
29
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
30
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
32
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
33
|
-
var variants = ['xxxsmall', 'xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge', 'xxlarge', 'xxxlarge', 'title', 'largeTitle', 'extraLight', 'light', 'semibold', 'bold', 'extrabold', 'primary', 'secondary', 'alternative', 'gray', 'darkGray', 'white', 'error', 'uppercase', 'lowercase'];
|
|
34
|
-
var UTLabel = /*#__PURE__*/function (_PureComponent) {
|
|
35
|
-
_inherits(UTLabel, _PureComponent);
|
|
36
|
-
var _super = _createSuper(UTLabel);
|
|
37
|
-
function UTLabel(props) {
|
|
38
|
-
var _this;
|
|
39
|
-
_classCallCheck(this, UTLabel);
|
|
40
|
-
_this = _super.call(this, props);
|
|
41
|
-
_defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
|
|
42
|
-
_this.setTitle();
|
|
43
|
-
});
|
|
44
|
-
_defineProperty(_assertThisInitialized(_this), "componentDidUpdate", function () {
|
|
45
|
-
_this.setTitle();
|
|
46
|
-
});
|
|
47
|
-
_defineProperty(_assertThisInitialized(_this), "setTitle", function () {
|
|
48
|
-
if (!_this.ref) return;
|
|
49
|
-
var _this$ref$getBounding = _this.ref.getBoundingClientRect(),
|
|
50
|
-
childWidth = _this$ref$getBounding.width;
|
|
51
|
-
var parent = _this.ref.parentElement;
|
|
52
|
-
if (!parent) return;
|
|
53
|
-
var _parent$getBoundingCl = parent.getBoundingClientRect(),
|
|
54
|
-
parentWidth = _parent$getBoundingCl.width;
|
|
21
|
+
/* eslint-disable react/no-children-prop */
|
|
55
22
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
23
|
+
var UTLabel = function UTLabel(_ref) {
|
|
24
|
+
var children = _ref.children,
|
|
25
|
+
theme = _ref.classes,
|
|
26
|
+
className = _ref.className,
|
|
27
|
+
markdownRenderers = _ref.markdownRenderers,
|
|
28
|
+
style = _ref.style,
|
|
29
|
+
title = _ref.title,
|
|
30
|
+
variant = _ref.variant,
|
|
31
|
+
withMarkdown = _ref.withMarkdown;
|
|
32
|
+
if (children == null) return null;
|
|
33
|
+
var Component = _constants.VARIANTS[variant] || _constants.VARIANTS[_constants.DEFAULT_PROPS.variant];
|
|
34
|
+
var classes = (0, _react.useMemo)(function () {
|
|
35
|
+
return (0, _classesUtils.mergeClasses)(theme, {
|
|
36
|
+
className: className
|
|
60
37
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
tag = _this$props.tag,
|
|
76
|
-
withoutMarkdown = _this$props.withoutMarkdown,
|
|
77
|
-
propStyle = _this$props.style;
|
|
78
|
-
var withHoverTitle = this.state.withHoverTitle;
|
|
79
|
-
var style = (0, _style.retrieveClassNamesFromProps)(variants, classes, this.props);
|
|
80
|
-
var handleCustomTag = function handleCustomTag(prop) {
|
|
81
|
-
var CustomTag = tag;
|
|
82
|
-
return /*#__PURE__*/_react.default.createElement(CustomTag, {
|
|
83
|
-
ref: function ref(_ref) {
|
|
84
|
-
return _this2.ref = _ref;
|
|
85
|
-
},
|
|
86
|
-
title: withHoverTitle ? prop.children || prop : '',
|
|
87
|
-
style: propStyle,
|
|
88
|
-
key: prop.children,
|
|
89
|
-
className: withoutMarkdown && "".concat(className, " ").concat(classes.base, " ").concat(style)
|
|
90
|
-
}, prop.children || prop);
|
|
91
|
-
};
|
|
92
|
-
var renderLinkComponent = function renderLinkComponent(prop) {
|
|
93
|
-
return /*#__PURE__*/_react.default.createElement("a", {
|
|
94
|
-
href: prop.href,
|
|
95
|
-
rel: "noopener noreferrer",
|
|
96
|
-
target: "_blank",
|
|
97
|
-
className: _stylesModule.default.link
|
|
98
|
-
}, prop.children);
|
|
99
|
-
};
|
|
100
|
-
var value = Array.isArray(children) ? children.join('') : isNaN(children) ? children : "".concat(children); // eslint-disable-line
|
|
101
|
-
|
|
102
|
-
return /*#__PURE__*/_react.default.createElement(_UTSkeleton.default, null, withoutMarkdown ? handleCustomTag(value) : /*#__PURE__*/_react.default.createElement(_reactMarkdown.default, {
|
|
103
|
-
source: value,
|
|
104
|
-
escapeHtml: false,
|
|
105
|
-
plugins: [_remarkBreaks.default],
|
|
106
|
-
unwrapDisallowed: true,
|
|
107
|
-
disallowedTypes: ['root', 'paragraph'],
|
|
108
|
-
className: "".concat(className, " ").concat(classes.base, " ").concat(style),
|
|
109
|
-
renderers: {
|
|
110
|
-
link: renderLinkComponent,
|
|
111
|
-
text: handleCustomTag
|
|
112
|
-
}
|
|
113
|
-
}, value));
|
|
114
|
-
}
|
|
115
|
-
}]);
|
|
116
|
-
return UTLabel;
|
|
117
|
-
}(_react.PureComponent);
|
|
118
|
-
UTLabel.defaultProps = {
|
|
119
|
-
tag: 'span'
|
|
38
|
+
});
|
|
39
|
+
return /*#__PURE__*/_react.default.createElement(_UTSkeleton.default, null, /*#__PURE__*/_react.default.createElement(Component, {
|
|
40
|
+
className: "".concat(classes.root, " ").concat(classes.className).trim(),
|
|
41
|
+
title: title,
|
|
42
|
+
style: style
|
|
43
|
+
}, withMarkdown && /*#__PURE__*/_react.default.createElement(_reactMarkdown.default, {
|
|
44
|
+
children: children,
|
|
45
|
+
components: markdownRenderers,
|
|
46
|
+
disallowedElements: ['p', 'blockquote'],
|
|
47
|
+
rehypePlugins: [_rehypeRaw.default],
|
|
48
|
+
remarkPlugins: [_remarkBreaks.default],
|
|
49
|
+
skipHtml: false,
|
|
50
|
+
unwrapDisallowed: true
|
|
51
|
+
}) || children));
|
|
120
52
|
};
|
|
53
|
+
UTLabel.defaultProps = _constants.DEFAULT_PROPS;
|
|
121
54
|
UTLabel.propTypes = {
|
|
122
55
|
classes: (0, _propTypes.objectOf)(_propTypes.string),
|
|
123
56
|
className: _propTypes.string,
|
|
124
|
-
|
|
125
|
-
|
|
57
|
+
markdownRenderers: (0, _propTypes.objectOf)(_propTypes.func),
|
|
58
|
+
// TODO: this "style" prop is for compatibility with the -base project only. Delete it when no longer needed
|
|
59
|
+
style: _propTypes.object,
|
|
60
|
+
title: _propTypes.string,
|
|
61
|
+
variant: _propTypes.string,
|
|
62
|
+
withMarkdown: _propTypes.bool
|
|
126
63
|
};
|
|
127
64
|
var _default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTLabel);
|
|
128
65
|
exports.default = _default;
|