@zohodesk/components 1.0.0-temp-243 → 1.0.0-temp-245
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/README.md +0 -4
- package/assets/Appearance/dark/mode/Component_DarkMode.module.css +4 -4
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +5 -0
- package/assets/Appearance/dark/themes/blue/blue_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/dark/themes/green/green_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/dark/themes/orange/orange_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/dark/themes/red/red_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/dark/themes/yellow/yellow_CTA_DarkModifyCategory.module.css +461 -8
- package/assets/Appearance/light/mode/Component_LightMode.module.css +6 -6
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +5 -0
- package/assets/Appearance/light/themes/blue/blue_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/light/themes/green/green_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/light/themes/orange/orange_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/light/themes/red/red_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/light/themes/yellow/yellow_CTA_LightModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +3 -3
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +5 -0
- package/assets/Appearance/pureDark/themes/blue/blue_CTA_PureDarkModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/themes/green/green_CTA_PureDarkModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/themes/orange/orange_CTA_PureDarkModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/themes/red/red_CTA_PureDarkModifyCategory.module.css +461 -8
- package/assets/Appearance/pureDark/themes/yellow/yellow_CTA_PureDarkModifyCategory.module.css +461 -8
- package/es/Provider/LibraryContext.js +11 -3
- package/es/v1/Label/Label.js +82 -33
- package/es/v1/Label/css/Label_v1.module.css +43 -0
- package/es/v1/Label/css/cssJSLogic.js +29 -0
- package/es/v1/Label/props/defaultProps.js +8 -10
- package/es/v1/Label/props/propTypes.js +21 -14
- package/lib/Provider/LibraryContext.js +11 -3
- package/lib/v1/Label/Label.js +90 -35
- package/lib/v1/Label/css/Label_v1.module.css +43 -0
- package/lib/v1/Label/css/cssJSLogic.js +31 -0
- package/lib/v1/Label/props/defaultProps.js +10 -12
- package/lib/v1/Label/props/propTypes.js +23 -16
- package/package.json +2 -2
package/es/v1/Label/Label.js
CHANGED
|
@@ -1,40 +1,89 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import React, { useContext, useEffect, useState } from 'react'; // props
|
|
2
|
+
|
|
3
|
+
import defaultProps from "./props/defaultProps";
|
|
4
|
+
import { propTypes } from "./props/propTypes"; // methods
|
|
5
|
+
|
|
6
|
+
import cssJSLogic from "./css/cssJSLogic";
|
|
7
|
+
import { mergeStyle } from '@zohodesk/utils'; // component registry
|
|
8
|
+
|
|
9
|
+
import { withComponentRegistrar } from '@zohodesk/dotkit/es/react/ComponentRegistry'; // components
|
|
10
|
+
|
|
11
|
+
import Flex from '@zohodesk/layout/es/Flex/Flex';
|
|
12
|
+
import Typography from "../../Typography/Typography"; // css
|
|
13
|
+
|
|
14
|
+
import defaultStyle from "./css/Label_v1.module.css";
|
|
15
|
+
|
|
16
|
+
const Label = props => {
|
|
7
17
|
const {
|
|
8
|
-
text,
|
|
9
|
-
type,
|
|
10
|
-
palette,
|
|
11
|
-
size,
|
|
12
|
-
clipped,
|
|
13
18
|
htmlFor,
|
|
14
|
-
title,
|
|
15
19
|
onClick,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
text,
|
|
21
|
+
customId,
|
|
22
|
+
testId,
|
|
23
|
+
customStyle,
|
|
24
|
+
tagAttributes,
|
|
25
|
+
a11yAttributes,
|
|
26
|
+
customProps,
|
|
27
|
+
isRequired,
|
|
28
|
+
isDisabled,
|
|
29
|
+
requiredType,
|
|
30
|
+
shouldHighlightRequired
|
|
22
31
|
} = props;
|
|
23
32
|
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
container: tagAttributes_container,
|
|
34
|
+
label: tagAttributes_label
|
|
35
|
+
} = tagAttributes;
|
|
36
|
+
const {
|
|
37
|
+
container: a11yAttributes_container,
|
|
38
|
+
label: a11yAttributes_label
|
|
39
|
+
} = a11yAttributes;
|
|
40
|
+
const {
|
|
41
|
+
container: customProps_container,
|
|
42
|
+
label: customProps_label
|
|
43
|
+
} = customProps;
|
|
44
|
+
const style = mergeStyle(defaultStyle, customStyle);
|
|
45
|
+
const {
|
|
46
|
+
labelClass,
|
|
47
|
+
requiredClass
|
|
48
|
+
} = cssJSLogic({
|
|
49
|
+
props: { ...props,
|
|
50
|
+
requiredType,
|
|
51
|
+
shouldHighlightRequired,
|
|
52
|
+
isRequired,
|
|
53
|
+
isDisabled
|
|
54
|
+
},
|
|
55
|
+
style
|
|
56
|
+
});
|
|
57
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
58
|
+
$ui_displayMode: "inline",
|
|
59
|
+
$ui_alignItems: "center",
|
|
60
|
+
$tagAttributes_container: {
|
|
61
|
+
'data-selector-id': customId,
|
|
62
|
+
...tagAttributes_container
|
|
63
|
+
},
|
|
64
|
+
$a11yAttributes_container: a11yAttributes_container,
|
|
65
|
+
testId: testId,
|
|
66
|
+
customId: customId,
|
|
67
|
+
...customProps_container
|
|
68
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
69
|
+
$ui_tagName: "label",
|
|
70
|
+
$ui_className: labelClass,
|
|
71
|
+
$i18n_dataTitle: text,
|
|
72
|
+
$tagAttributes_text: {
|
|
73
|
+
htmlFor: htmlFor,
|
|
74
|
+
onClick: onClick,
|
|
75
|
+
...tagAttributes_label
|
|
76
|
+
},
|
|
77
|
+
$a11yAttributes_text: a11yAttributes_label,
|
|
78
|
+
...customProps_label
|
|
79
|
+
}, text), isRequired && requiredType === 'text' ? /*#__PURE__*/React.createElement(Typography, {
|
|
80
|
+
$ui_tagName: "span",
|
|
81
|
+
$ui_className: requiredClass
|
|
82
|
+
}, "(Required)") : '');
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default withComponentRegistrar(Label, {
|
|
86
|
+
name: 'ZDC_v1_Label'
|
|
87
|
+
});
|
|
39
88
|
Label.defaultProps = defaultProps;
|
|
40
89
|
Label.propTypes = propTypes;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.label {
|
|
2
|
+
font-size: var(--zd_font_size14) ;
|
|
3
|
+
color: var(--zdt_v1_label_text);
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.dotted {
|
|
8
|
+
composes: dotted from '../../../common/common.module.css';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.required {
|
|
12
|
+
color: var(--zdt_v1_label_mandatory_text);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.asterisk:after {
|
|
16
|
+
content: "*";
|
|
17
|
+
color: var(--zdt_v1_label_mandatory_text);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[dir=ltr] .asterisk:after {
|
|
21
|
+
padding-left: var(--zd_size2) ;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[dir=rtl] .asterisk:after {
|
|
25
|
+
padding-right: var(--zd_size2) ;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.requiredTxt {
|
|
29
|
+
color: var(--zdt_v1_label_mandatory_text);
|
|
30
|
+
font-size: var(--zd_font_size14) ;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[dir=ltr] .requiredTxt {
|
|
34
|
+
margin-left: var(--zd_size5) ;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[dir=rtl] .requiredTxt {
|
|
38
|
+
margin-right: var(--zd_size5) ;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.disabled {
|
|
42
|
+
color: var(--zdt_v1_label_disabled_text);
|
|
43
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import compileClassNames from '@zohodesk/utils/es/compileClassNames';
|
|
2
|
+
export default function cssJSLogic(_ref) {
|
|
3
|
+
let {
|
|
4
|
+
props,
|
|
5
|
+
style
|
|
6
|
+
} = _ref;
|
|
7
|
+
const {
|
|
8
|
+
isClipped,
|
|
9
|
+
requiredType,
|
|
10
|
+
shouldHighlightRequired,
|
|
11
|
+
isRequired,
|
|
12
|
+
isDisabled
|
|
13
|
+
} = props; // const shouldHighlightMandatory = localStorage?.getItem('mandatoryAppearance') === 'true';
|
|
14
|
+
|
|
15
|
+
let labelClass = compileClassNames({
|
|
16
|
+
[style.label]: true,
|
|
17
|
+
[style.dotted]: isClipped,
|
|
18
|
+
[style.asterisk]: isRequired && requiredType === 'asterisk',
|
|
19
|
+
[style.required]: isRequired && shouldHighlightRequired,
|
|
20
|
+
[style.disabled]: isDisabled
|
|
21
|
+
});
|
|
22
|
+
let requiredClass = compileClassNames({
|
|
23
|
+
[style.requiredTxt]: true
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
labelClass,
|
|
27
|
+
requiredClass
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
customClass: '',
|
|
10
|
-
dataSelectorId: 'label'
|
|
1
|
+
export default {
|
|
2
|
+
customProps: {},
|
|
3
|
+
tagAttributes: {},
|
|
4
|
+
a11yAttributes: {},
|
|
5
|
+
customStyle: {},
|
|
6
|
+
shouldHighlightRequired: false,
|
|
7
|
+
isDisabled: false,
|
|
8
|
+
isClipped: true
|
|
11
9
|
};
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
export
|
|
3
|
-
clipped: PropTypes.bool,
|
|
4
|
-
dataId: PropTypes.string,
|
|
5
|
-
dataSelectorId: PropTypes.string,
|
|
2
|
+
export default {
|
|
6
3
|
htmlFor: PropTypes.string,
|
|
7
|
-
onClick: PropTypes.func,
|
|
8
|
-
palette: PropTypes.oneOf(['default', 'primary', 'secondary', 'danger', 'mandatory', 'disable', 'dark']),
|
|
9
|
-
size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large']),
|
|
10
4
|
text: PropTypes.string,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
onClick: PropTypes.func,
|
|
6
|
+
a11yAttributes: PropTypes.shape({
|
|
7
|
+
container: PropTypes.object,
|
|
8
|
+
label: PropTypes.object
|
|
9
|
+
}),
|
|
10
|
+
tagAttributes: PropTypes.shape({
|
|
11
|
+
container: PropTypes.object,
|
|
12
|
+
label: PropTypes.object
|
|
13
|
+
}),
|
|
14
|
+
customProps: PropTypes.shape({
|
|
15
|
+
container: PropTypes.object,
|
|
16
|
+
label: PropTypes.object
|
|
17
17
|
}),
|
|
18
|
-
|
|
18
|
+
customId: PropTypes.string,
|
|
19
|
+
testId: PropTypes.string,
|
|
20
|
+
customStyle: PropTypes.object,
|
|
21
|
+
requiredType: PropTypes.oneOf(['asterisk', 'text']),
|
|
22
|
+
shouldHighlightRequired: PropTypes.bool,
|
|
23
|
+
isClipped: PropTypes.bool,
|
|
24
|
+
isRequired: PropTypes.bool,
|
|
25
|
+
isDisabled: PropTypes.bool
|
|
19
26
|
};
|
|
@@ -46,6 +46,8 @@ var LibraryContextProvider = function LibraryContextProvider(_ref) {
|
|
|
46
46
|
hasTagColorInheritedToText = _ref.hasTagColorInheritedToText,
|
|
47
47
|
shouldIndicateSwitchState = _ref.shouldIndicateSwitchState,
|
|
48
48
|
shouldStrikeThroughDisabledButton = _ref.shouldStrikeThroughDisabledButton,
|
|
49
|
+
requiredType = _ref.requiredType,
|
|
50
|
+
shouldHighlightRequired = _ref.shouldHighlightRequired,
|
|
49
51
|
children = _ref.children;
|
|
50
52
|
|
|
51
53
|
var _useState = (0, _react.useState)({
|
|
@@ -54,7 +56,9 @@ var LibraryContextProvider = function LibraryContextProvider(_ref) {
|
|
|
54
56
|
coloredTagVariant: coloredTagVariant,
|
|
55
57
|
hasTagColorInheritedToText: hasTagColorInheritedToText,
|
|
56
58
|
shouldIndicateSwitchState: shouldIndicateSwitchState,
|
|
57
|
-
shouldStrikeThroughDisabledButton: shouldStrikeThroughDisabledButton
|
|
59
|
+
shouldStrikeThroughDisabledButton: shouldStrikeThroughDisabledButton,
|
|
60
|
+
requiredType: requiredType,
|
|
61
|
+
shouldHighlightRequired: shouldHighlightRequired
|
|
58
62
|
}),
|
|
59
63
|
_useState2 = _slicedToArray(_useState, 2),
|
|
60
64
|
value = _useState2[0],
|
|
@@ -80,7 +84,9 @@ LibraryContextProvider.propTypes = {
|
|
|
80
84
|
hasTagColorInheritedToText: _propTypes["default"].bool,
|
|
81
85
|
direction: _propTypes["default"].string,
|
|
82
86
|
shouldIndicateSwitchState: _propTypes["default"].bool,
|
|
83
|
-
shouldStrikeThroughDisabledButton: _propTypes["default"].bool
|
|
87
|
+
shouldStrikeThroughDisabledButton: _propTypes["default"].bool,
|
|
88
|
+
requiredType: _propTypes["default"].oneOf(['asterisk', 'text']),
|
|
89
|
+
shouldHighlightRequired: _propTypes["default"].bool
|
|
84
90
|
};
|
|
85
91
|
LibraryContextProvider.defaultProps = {
|
|
86
92
|
isReducedMotion: (0, _Config.getLibraryConfig)('isReducedMotion'),
|
|
@@ -88,7 +94,9 @@ LibraryContextProvider.defaultProps = {
|
|
|
88
94
|
coloredTagVariant: 'bold',
|
|
89
95
|
hasTagColorInheritedToText: true,
|
|
90
96
|
shouldIndicateSwitchState: false,
|
|
91
|
-
shouldStrikeThroughDisabledButton: false
|
|
97
|
+
shouldStrikeThroughDisabledButton: false,
|
|
98
|
+
requiredType: 'asterisk',
|
|
99
|
+
shouldHighlightRequired: true
|
|
92
100
|
};
|
|
93
101
|
var _default = LibraryContextProvider;
|
|
94
102
|
exports["default"] = _default;
|
package/lib/v1/Label/Label.js
CHANGED
|
@@ -1,51 +1,106 @@
|
|
|
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); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports["default"] =
|
|
8
|
+
exports["default"] = void 0;
|
|
7
9
|
|
|
8
|
-
var _react =
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
11
|
|
|
10
|
-
var _defaultProps = require("./props/defaultProps");
|
|
12
|
+
var _defaultProps = _interopRequireDefault(require("./props/defaultProps"));
|
|
11
13
|
|
|
12
14
|
var _propTypes = require("./props/propTypes");
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var _cssJSLogic2 = _interopRequireDefault(require("./css/cssJSLogic"));
|
|
17
|
+
|
|
18
|
+
var _utils = require("@zohodesk/utils");
|
|
19
|
+
|
|
20
|
+
var _ComponentRegistry = require("@zohodesk/dotkit/es/react/ComponentRegistry");
|
|
21
|
+
|
|
22
|
+
var _Flex = _interopRequireDefault(require("@zohodesk/layout/es/Flex/Flex"));
|
|
15
23
|
|
|
16
|
-
var
|
|
24
|
+
var _Typography = _interopRequireDefault(require("../../Typography/Typography"));
|
|
25
|
+
|
|
26
|
+
var _Label_v1Module = _interopRequireDefault(require("./css/Label_v1.module.css"));
|
|
17
27
|
|
|
18
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
29
|
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
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); }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
35
|
+
|
|
36
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
37
|
+
|
|
38
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
39
|
+
|
|
40
|
+
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; }
|
|
41
|
+
|
|
42
|
+
var Label = function Label(props) {
|
|
43
|
+
var htmlFor = props.htmlFor,
|
|
28
44
|
onClick = props.onClick,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
text = props.text,
|
|
46
|
+
customId = props.customId,
|
|
47
|
+
testId = props.testId,
|
|
48
|
+
customStyle = props.customStyle,
|
|
49
|
+
tagAttributes = props.tagAttributes,
|
|
50
|
+
a11yAttributes = props.a11yAttributes,
|
|
51
|
+
customProps = props.customProps,
|
|
52
|
+
isRequired = props.isRequired,
|
|
53
|
+
isDisabled = props.isDisabled,
|
|
54
|
+
requiredType = props.requiredType,
|
|
55
|
+
shouldHighlightRequired = props.shouldHighlightRequired;
|
|
56
|
+
var tagAttributes_container = tagAttributes.container,
|
|
57
|
+
tagAttributes_label = tagAttributes.label;
|
|
58
|
+
var a11yAttributes_container = a11yAttributes.container,
|
|
59
|
+
a11yAttributes_label = a11yAttributes.label;
|
|
60
|
+
var customProps_container = customProps.container,
|
|
61
|
+
customProps_label = customProps.label;
|
|
62
|
+
var style = (0, _utils.mergeStyle)(_Label_v1Module["default"], customStyle);
|
|
63
|
+
|
|
64
|
+
var _cssJSLogic = (0, _cssJSLogic2["default"])({
|
|
65
|
+
props: _objectSpread(_objectSpread({}, props), {}, {
|
|
66
|
+
requiredType: requiredType,
|
|
67
|
+
shouldHighlightRequired: shouldHighlightRequired,
|
|
68
|
+
isRequired: isRequired,
|
|
69
|
+
isDisabled: isDisabled
|
|
70
|
+
}),
|
|
71
|
+
style: style
|
|
72
|
+
}),
|
|
73
|
+
labelClass = _cssJSLogic.labelClass,
|
|
74
|
+
requiredClass = _cssJSLogic.requiredClass;
|
|
75
|
+
|
|
76
|
+
return /*#__PURE__*/_react["default"].createElement(_Flex["default"], _extends({
|
|
77
|
+
$ui_displayMode: "inline",
|
|
78
|
+
$ui_alignItems: "center",
|
|
79
|
+
$tagAttributes_container: _objectSpread({
|
|
80
|
+
'data-selector-id': customId
|
|
81
|
+
}, tagAttributes_container),
|
|
82
|
+
$a11yAttributes_container: a11yAttributes_container,
|
|
83
|
+
testId: testId,
|
|
84
|
+
customId: customId
|
|
85
|
+
}, customProps_container), /*#__PURE__*/_react["default"].createElement(_Typography["default"], _extends({
|
|
86
|
+
$ui_tagName: "label",
|
|
87
|
+
$ui_className: labelClass,
|
|
88
|
+
$i18n_dataTitle: text,
|
|
89
|
+
$tagAttributes_text: _objectSpread({
|
|
90
|
+
htmlFor: htmlFor,
|
|
91
|
+
onClick: onClick
|
|
92
|
+
}, tagAttributes_label),
|
|
93
|
+
$a11yAttributes_text: a11yAttributes_label
|
|
94
|
+
}, customProps_label), text), isRequired && requiredType === 'text' ? /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
95
|
+
$ui_tagName: "span",
|
|
96
|
+
$ui_className: requiredClass
|
|
97
|
+
}, "(Required)") : '');
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
var _default = (0, _ComponentRegistry.withComponentRegistrar)(Label, {
|
|
101
|
+
name: 'ZDC_v1_Label'
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
exports["default"] = _default;
|
|
105
|
+
Label.defaultProps = _defaultProps["default"];
|
|
51
106
|
Label.propTypes = _propTypes.propTypes;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.label {
|
|
2
|
+
font-size: var(--zd_font_size14) ;
|
|
3
|
+
color: var(--zdt_v1_label_text);
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.dotted {
|
|
8
|
+
composes: dotted from '../../../common/common.module.css';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.required {
|
|
12
|
+
color: var(--zdt_v1_label_mandatory_text);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.asterisk:after {
|
|
16
|
+
content: "*";
|
|
17
|
+
color: var(--zdt_v1_label_mandatory_text);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[dir=ltr] .asterisk:after {
|
|
21
|
+
padding-left: var(--zd_size2) ;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[dir=rtl] .asterisk:after {
|
|
25
|
+
padding-right: var(--zd_size2) ;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.requiredTxt {
|
|
29
|
+
color: var(--zdt_v1_label_mandatory_text);
|
|
30
|
+
font-size: var(--zd_font_size14) ;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[dir=ltr] .requiredTxt {
|
|
34
|
+
margin-left: var(--zd_size5) ;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[dir=rtl] .requiredTxt {
|
|
38
|
+
margin-right: var(--zd_size5) ;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.disabled {
|
|
42
|
+
color: var(--zdt_v1_label_disabled_text);
|
|
43
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = cssJSLogic;
|
|
7
|
+
|
|
8
|
+
var _compileClassNames3 = _interopRequireDefault(require("@zohodesk/utils/es/compileClassNames"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
function cssJSLogic(_ref) {
|
|
15
|
+
var _compileClassNames;
|
|
16
|
+
|
|
17
|
+
var props = _ref.props,
|
|
18
|
+
style = _ref.style;
|
|
19
|
+
var isClipped = props.isClipped,
|
|
20
|
+
requiredType = props.requiredType,
|
|
21
|
+
shouldHighlightRequired = props.shouldHighlightRequired,
|
|
22
|
+
isRequired = props.isRequired,
|
|
23
|
+
isDisabled = props.isDisabled; // const shouldHighlightMandatory = localStorage?.getItem('mandatoryAppearance') === 'true';
|
|
24
|
+
|
|
25
|
+
var labelClass = (0, _compileClassNames3["default"])((_compileClassNames = {}, _defineProperty(_compileClassNames, style.label, true), _defineProperty(_compileClassNames, style.dotted, isClipped), _defineProperty(_compileClassNames, style.asterisk, isRequired && requiredType === 'asterisk'), _defineProperty(_compileClassNames, style.required, isRequired && shouldHighlightRequired), _defineProperty(_compileClassNames, style.disabled, isDisabled), _compileClassNames));
|
|
26
|
+
var requiredClass = (0, _compileClassNames3["default"])(_defineProperty({}, style.requiredTxt, true));
|
|
27
|
+
return {
|
|
28
|
+
labelClass: labelClass,
|
|
29
|
+
requiredClass: requiredClass
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
customClass: '',
|
|
16
|
-
dataSelectorId: 'label'
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
customProps: {},
|
|
9
|
+
tagAttributes: {},
|
|
10
|
+
a11yAttributes: {},
|
|
11
|
+
customStyle: {},
|
|
12
|
+
shouldHighlightRequired: false,
|
|
13
|
+
isDisabled: false,
|
|
14
|
+
isClipped: true
|
|
17
15
|
};
|
|
18
|
-
exports
|
|
16
|
+
exports["default"] = _default;
|
|
@@ -3,28 +3,35 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
clipped: _propTypes["default"].bool,
|
|
14
|
-
dataId: _propTypes["default"].string,
|
|
15
|
-
dataSelectorId: _propTypes["default"].string,
|
|
12
|
+
var _default = {
|
|
16
13
|
htmlFor: _propTypes["default"].string,
|
|
17
|
-
onClick: _propTypes["default"].func,
|
|
18
|
-
palette: _propTypes["default"].oneOf(['default', 'primary', 'secondary', 'danger', 'mandatory', 'disable', 'dark']),
|
|
19
|
-
size: _propTypes["default"].oneOf(['xsmall', 'small', 'medium', 'large']),
|
|
20
14
|
text: _propTypes["default"].string,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
onClick: _propTypes["default"].func,
|
|
16
|
+
a11yAttributes: _propTypes["default"].shape({
|
|
17
|
+
container: _propTypes["default"].object,
|
|
18
|
+
label: _propTypes["default"].object
|
|
19
|
+
}),
|
|
20
|
+
tagAttributes: _propTypes["default"].shape({
|
|
21
|
+
container: _propTypes["default"].object,
|
|
22
|
+
label: _propTypes["default"].object
|
|
23
|
+
}),
|
|
24
|
+
customProps: _propTypes["default"].shape({
|
|
25
|
+
container: _propTypes["default"].object,
|
|
26
|
+
label: _propTypes["default"].object
|
|
27
27
|
}),
|
|
28
|
-
|
|
28
|
+
customId: _propTypes["default"].string,
|
|
29
|
+
testId: _propTypes["default"].string,
|
|
30
|
+
customStyle: _propTypes["default"].object,
|
|
31
|
+
requiredType: _propTypes["default"].oneOf(['asterisk', 'text']),
|
|
32
|
+
shouldHighlightRequired: _propTypes["default"].bool,
|
|
33
|
+
isClipped: _propTypes["default"].bool,
|
|
34
|
+
isRequired: _propTypes["default"].bool,
|
|
35
|
+
isDisabled: _propTypes["default"].bool
|
|
29
36
|
};
|
|
30
|
-
exports
|
|
37
|
+
exports["default"] = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/components",
|
|
3
|
-
"version": "1.0.0-temp-
|
|
3
|
+
"version": "1.0.0-temp-245",
|
|
4
4
|
"main": "es/index.js",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@testing-library/react": "^11.2.5",
|
|
75
75
|
"@testing-library/react-hooks": "^7.0.2",
|
|
76
76
|
"@testing-library/user-event": "^13.0.10",
|
|
77
|
-
"@zohodesk-private/color-variable-preprocessor": "1.
|
|
77
|
+
"@zohodesk-private/color-variable-preprocessor": "1.2.0",
|
|
78
78
|
"@zohodesk-private/css-variable-migrator": "1.0.9",
|
|
79
79
|
"@zohodesk-private/node-plugins": "1.1.13",
|
|
80
80
|
"@zohodesk-private/react-prop-validator": "1.2.3",
|