@commercetools-uikit/field-label 0.0.0-canary-2021830134526
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/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/commercetools-uikit-field-label.cjs.d.ts +2 -0
- package/dist/commercetools-uikit-field-label.cjs.dev.js +119 -0
- package/dist/commercetools-uikit-field-label.cjs.js +7 -0
- package/dist/commercetools-uikit-field-label.cjs.prod.js +96 -0
- package/dist/commercetools-uikit-field-label.esm.js +104 -0
- package/dist/declarations/src/export-types.d.ts +2 -0
- package/dist/declarations/src/field-label.d.ts +22 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 commercetools GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<!-- THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -->
|
|
2
|
+
<!-- This file is created by the `yarn generate-readme` script. -->
|
|
3
|
+
|
|
4
|
+
# FieldLabel
|
|
5
|
+
|
|
6
|
+
## Description
|
|
7
|
+
|
|
8
|
+
The FieldLabel component represents the label for a field in a form. This component can also be used to better explain an input field and to guide the user to fill a form.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
yarn add @commercetools-uikit/field-label
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
npm --save install @commercetools-uikit/field-label
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Additionally install the peer dependencies (if not present)
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
yarn add react
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
npm --save install react
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```jsx
|
|
33
|
+
import { defineMessage, FormattedMessage } from 'react-intl';
|
|
34
|
+
import FlatButton from '@commercetools-uikit/flat-button';
|
|
35
|
+
import FieldLabel from '@commercetools-uikit/field-label';
|
|
36
|
+
import { WarningIcon } from '@commercetools-uikit/icons';
|
|
37
|
+
|
|
38
|
+
const messages = defineMessage();
|
|
39
|
+
|
|
40
|
+
const Example = () => (
|
|
41
|
+
<FieldLabel
|
|
42
|
+
title={<FormattedMessage {...messages.title} />}
|
|
43
|
+
hasRequiredIndicator={true}
|
|
44
|
+
onInfoButtonClick={() => {}}
|
|
45
|
+
hint={<FormattedMessage {...messages.hint} />}
|
|
46
|
+
hintIcon={<WarningIcon />}
|
|
47
|
+
description={<FormattedMessage {...messages.description} />}
|
|
48
|
+
badge={<FlatButton tone="primary" label="show" />}
|
|
49
|
+
htmlFor="sampleInput"
|
|
50
|
+
horizontalConstraint={7}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export default Example;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Properties
|
|
58
|
+
|
|
59
|
+
| Props | Type | Required | Default | Description |
|
|
60
|
+
| ---------------------- | ----------------------------------------------------------------------------------------------------- | :------: | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
61
|
+
| `title` | `union`<br/>Possible values:<br/>`string , ReactNode` | ✅ | | Title of the label |
|
|
62
|
+
| `hint` | `union`<br/>Possible values:<br/>`string , ReactNode` | | | Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas description can describe it in more depth. Can also receive a hintIcon. |
|
|
63
|
+
| `description` | `union`<br/>Possible values:<br/>`string , ReactNode` | | | Provides a description for the title. |
|
|
64
|
+
| `onInfoButtonClick` | `Function`<br/>[See signature.](#signature-onInfoButtonClick) | | | Function called when info button is pressed. Info button will only be visible when this prop is passed. |
|
|
65
|
+
| `tone` | `union`<br/>Possible values:<br/>`'primary' , 'inverted'` | | | Indicates the tone to be applied to the label |
|
|
66
|
+
| `hintIcon` | `ReactElement` | | | Icon to be displayed beside the hint text. Will only get rendered when hint is passed as well. |
|
|
67
|
+
| `badge` | `ReactNode` | | | Badge to be displayed beside the label. Might be used to display additional information about the content of the field (E.g verified email) |
|
|
68
|
+
| `hasRequiredIndicator` | `boolean` | | | Indicates if the labeled field is required in a form |
|
|
69
|
+
| `htmlFor` | `string` | | | The for HTML attribute, used to reference form elements with the related attribute id or aria-labelledby. |
|
|
70
|
+
| `id` | `string` | | | The id HTML attribute, used to reference non-form elements with the related attribute aria-labelledby. |
|
|
71
|
+
| `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | `'scale'` | Horizontal size limit of the label. |
|
|
72
|
+
|
|
73
|
+
## Signatures
|
|
74
|
+
|
|
75
|
+
### Signature `onInfoButtonClick`
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
(
|
|
79
|
+
event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>
|
|
80
|
+
) => void
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## `hintIcon`
|
|
84
|
+
|
|
85
|
+
The `hintIcon` also accepts a custom `color` while defaulting to `warning` in the case above. The `hintIcon` does **not** support the `size` prop, and will always be rendered in the size `medium`.
|
|
86
|
+
|
|
87
|
+
```diff
|
|
88
|
+
<FieldLabel
|
|
89
|
+
title={<FormattedMessage {...messages.title} />}
|
|
90
|
+
hasRequiredIndicator={true}
|
|
91
|
+
onInfoButtonClick={() => {}} />}
|
|
92
|
+
hint={<FormattedMessage {...messages.hint} />}
|
|
93
|
+
- hintIcon={<WarningIcon />}
|
|
94
|
+
+ hintIcon={<WarningIcon color="primary" />}
|
|
95
|
+
description={<FormattedMessage {...messages.description} />}
|
|
96
|
+
badge={<FlatButton tone="primary" label="show" />}
|
|
97
|
+
htmlFor="sampleInput"
|
|
98
|
+
horizontalConstraint={7}
|
|
99
|
+
/>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## `hint` vs `description`
|
|
103
|
+
|
|
104
|
+
Most fields will only use the `description` which provides more information about what the entered value will be used for.
|
|
105
|
+
|
|
106
|
+
The `hint` however is used to show additional information about the value the user enters. It can show the allowed characters. It can also show whether the entered value has errors (like a reference no longer existing in an attribute) when the form is loaded for the first time.
|
|
107
|
+
|
|
108
|
+
Neither of them should be used for form validation.
|
|
109
|
+
|
|
110
|
+
## Dos and don'ts
|
|
111
|
+
|
|
112
|
+
Recommended to be used in vertical forms. (E.g input field below the label, and not besides).
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _pt = require('prop-types');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var utils = require('@commercetools-uikit/utils');
|
|
8
|
+
require('@emotion/react');
|
|
9
|
+
var IconButton = require('@commercetools-uikit/icon-button');
|
|
10
|
+
var icons = require('@commercetools-uikit/icons');
|
|
11
|
+
var Text = require('@commercetools-uikit/text');
|
|
12
|
+
var Constraints = require('@commercetools-uikit/constraints');
|
|
13
|
+
var Stack = require('@commercetools-uikit/spacings-stack');
|
|
14
|
+
var Inline = require('@commercetools-uikit/spacings-inline');
|
|
15
|
+
var Label = require('@commercetools-uikit/label');
|
|
16
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
17
|
+
|
|
18
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var _pt__default = /*#__PURE__*/_interopDefault(_pt);
|
|
21
|
+
var IconButton__default = /*#__PURE__*/_interopDefault(IconButton);
|
|
22
|
+
var Text__default = /*#__PURE__*/_interopDefault(Text);
|
|
23
|
+
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
24
|
+
var Stack__default = /*#__PURE__*/_interopDefault(Stack);
|
|
25
|
+
var Inline__default = /*#__PURE__*/_interopDefault(Inline);
|
|
26
|
+
var Label__default = /*#__PURE__*/_interopDefault(Label);
|
|
27
|
+
|
|
28
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
29
|
+
|
|
30
|
+
var _ref = process.env.NODE_ENV === "production" ? {
|
|
31
|
+
name: "skgbeu",
|
|
32
|
+
styles: "display:flex;justify-content:flex-end"
|
|
33
|
+
} : {
|
|
34
|
+
name: "pfzph7-FieldLabel",
|
|
35
|
+
styles: "display:flex;justify-content:flex-end;label:FieldLabel;",
|
|
36
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZpZWxkLWxhYmVsLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFnSm9CIiwiZmlsZSI6ImZpZWxkLWxhYmVsLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7XG4gIGNsb25lRWxlbWVudCxcbiAgTW91c2VFdmVudCxcbiAgS2V5Ym9hcmRFdmVudCxcbiAgUmVhY3RFbGVtZW50LFxuICBSZWFjdE5vZGUsXG59IGZyb20gJ3JlYWN0JztcbmltcG9ydCB7IHdhcm5pbmcgfSBmcm9tICdAY29tbWVyY2V0b29scy11aWtpdC91dGlscyc7XG5pbXBvcnQgeyBjc3MgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5pbXBvcnQgSWNvbkJ1dHRvbiBmcm9tICdAY29tbWVyY2V0b29scy11aWtpdC9pY29uLWJ1dHRvbic7XG5pbXBvcnQgeyBJbmZvcm1hdGlvbkljb24gfSBmcm9tICdAY29tbWVyY2V0b29scy11aWtpdC9pY29ucyc7XG5pbXBvcnQgVGV4dCBmcm9tICdAY29tbWVyY2V0b29scy11aWtpdC90ZXh0JztcbmltcG9ydCBDb25zdHJhaW50cyBmcm9tICdAY29tbWVyY2V0b29scy11aWtpdC9jb25zdHJhaW50cyc7XG5pbXBvcnQgU3RhY2sgZnJvbSAnQGNvbW1lcmNldG9vbHMtdWlraXQvc3BhY2luZ3Mtc3RhY2snO1xuaW1wb3J0IElubGluZSBmcm9tICdAY29tbWVyY2V0b29scy11aWtpdC9zcGFjaW5ncy1pbmxpbmUnO1xuaW1wb3J0IExhYmVsIGZyb20gJ0Bjb21tZXJjZXRvb2xzLXVpa2l0L2xhYmVsJztcblxuZXhwb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T17cHJvcHMuaGFzUmVxdWlyZWRJbmRpY2F0b3J9XG4gICAgICAgICAgICAgIHRvbmU9e3Byb3BzLnRvbmV9XG4gICAgICAgICAgICAgIGlkPXtwcm9wcy5pZH1cbiAgICAgICAgICAgICAgaHRtbEZvcj17cHJvcHMuaHRtbEZvcn1cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAge3Byb3BzLnRpdGxlfVxuICAgICAgICAgICAgPC9MYWJlbD5cbiAgICAgICAgICA8L1RleHQuV3JhcD5cbiAgICAgICAgICB7cHJvcHMub25JbmZvQnV0dG9uQ2xpY2sgJiYgKFxuICAgICAgICAgICAgPEljb25CdXR0b25cbiAgICAgICAgICAgICAgbGFiZWw9XCJNb3JlIEluZm9cIlxuICAgICAgICAgICAgICBpY29uPXs8SW5mb3JtYXRpb25JY29uIHNpemU9XCJtZWRpdW1cIiAvPn1cbiAgICAgICAgICAgICAgc2l6ZT1cInNtYWxsXCJcbiAgICAgICAgICAgICAgb25DbGljaz17cHJvcHMub25JbmZvQnV0dG9uQ2xpY2t9XG4gICAgICAgICAgICAvPlxuICAgICAgICAgICl9XG4gICAgICAgIDwvSW5saW5lPlxuXG4gICAgICAgIHtwcm9wcy5oaW50ICYmIChcbiAgICAgICAgICA8SW5saW5lIGFsaWduSXRlbXM9XCJmbGV4U3RhcnRcIiBzY2FsZT1cInhzXCI+XG4gICAgICAgICAgICB7cHJvcHMuaGludEljb24gJiYgKFxuICAgICAgICAgICAgICA8SW5saW5lPlxuICAgICAgICAgICAgICAgIHtjbG9uZUVsZW1lbnQocHJvcHMuaGludEljb24sIHtcbiAgICAgICAgICAgICAgICAgIC8vIEZJWE1FOiBhZGQgcHJvcGVyIHRvbmUgd2hlbiB0b25lcyBhcmUgcmVmYWN0b3JlZFxuICAgICAgICAgICAgICAgICAgc2l6ZTogJ21lZGl1bScsXG4gICAgICAgICAgICAgICAgICBjb2xvcjogcHJvcHMuaGludEljb24ucHJvcHMuY29sb3IgfHwgJ3dhcm5pbmcnLFxuICAgICAgICAgICAgICAgIH0pfVxuICAgICAgICAgICAgICA8L0lubGluZT5cbiAgICAgICAgICAgICl9XG4gICAgICAgICAgICB7cHJvcHMuaGludCAmJiAoXG4gICAgICAgICAgICAgIDxUZXh0LkRldGFpbCB0b25lPXtwcm9wcy50b25lfT57cHJvcHMuaGludH08L1RleHQuRGV0YWlsPlxuICAgICAgICAgICAgKX1cbiAgICAgICAgICA8L0lubGluZT5cbiAgICAgICAgKX1cbiAgICAgICAge3Byb3BzLmRlc2NyaXB0aW9uICYmIChcbiAgICAgICAgICA8VGV4dC5XcmFwPlxuICAgICAgICAgICAgPFRleHQuRGV0YWlsIHRvbmU9e3Byb3BzLnRvbmV9Pntwcm9wcy5kZXNjcmlwdGlvbn08L1RleHQuRGV0YWlsPlxuICAgICAgICAgIDwvVGV4dC5XcmFwPlxuICAgICAgICApfVxuXG4gICAgICAgIHtwcm9wcy5iYWRnZSAmJiAoXG4gICAgICAgICAgPGRpdlxuICAgICAgICAgICAgY3NzPXtjc3NgXG4gICAgICAgICAgICAgIGRpc3BsYXk6IGZsZXg7XG4gICAgICAgICAgICAgIGp1c3RpZnktY29udGVudDogZmxleC1lbmQ7XG4gICAgICAgICAgICBgfVxuICAgICAgICAgID5cbiAgICAgICAgICAgIHtwcm9wcy5iYWRnZX1cbiAgICAgICAgICA8L2Rpdj5cbiAgICAgICAgKX1cbiAgICAgIDwvU3RhY2s+XG4gICAgPC9Db25zdHJhaW50cy5Ib3Jpem9udGFsPlxuICApO1xufTtcblxuRmllbGRMYWJlbC5kaXNwbGF5TmFtZSA9ICdGaWVsZExhYmVsJztcbkZpZWxkTGFiZWwuZGVmYXVsdFByb3BzID0ge1xuICBob3Jpem9udGFsQ29uc3RyYWludDogJ3NjYWxlJyxcbn07XG5cbmV4cG9ydCBkZWZhdWx0IEZpZWxkTGFiZWw7XG4iXX0= */",
|
|
37
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var FieldLabel = function FieldLabel(props) {
|
|
41
|
+
if (props.hintIcon) {
|
|
42
|
+
process.env.NODE_ENV !== "production" ? utils.warning(props.hintIcon.props.size === undefined, 'ui-kit/FieldLabel: setting `hintIcon` size is not supported.') : void 0;
|
|
43
|
+
process.env.NODE_ENV !== "production" ? utils.warning(Boolean(props.hint), 'ui-kit/FieldLabel: `hint` is required when `hintIcon` is provided') : void 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return jsxRuntime.jsx(Constraints__default['default'].Horizontal, {
|
|
47
|
+
max: props.horizontalConstraint,
|
|
48
|
+
children: jsxRuntime.jsxs(Stack__default['default'], {
|
|
49
|
+
scale: "xs",
|
|
50
|
+
children: [jsxRuntime.jsxs(Inline__default['default'], {
|
|
51
|
+
alignItems: "flexStart",
|
|
52
|
+
scale: "xs",
|
|
53
|
+
children: [jsxRuntime.jsx(Text__default['default'].Wrap, {
|
|
54
|
+
children: jsxRuntime.jsx(Label__default['default'], {
|
|
55
|
+
isBold: true,
|
|
56
|
+
isRequiredIndicatorVisible: props.hasRequiredIndicator,
|
|
57
|
+
tone: props.tone,
|
|
58
|
+
id: props.id,
|
|
59
|
+
htmlFor: props.htmlFor,
|
|
60
|
+
children: props.title
|
|
61
|
+
})
|
|
62
|
+
}), props.onInfoButtonClick && jsxRuntime.jsx(IconButton__default['default'], {
|
|
63
|
+
label: "More Info",
|
|
64
|
+
icon: jsxRuntime.jsx(icons.InformationIcon, {
|
|
65
|
+
size: "medium"
|
|
66
|
+
}),
|
|
67
|
+
size: "small",
|
|
68
|
+
onClick: props.onInfoButtonClick
|
|
69
|
+
})]
|
|
70
|
+
}), props.hint && jsxRuntime.jsxs(Inline__default['default'], {
|
|
71
|
+
alignItems: "flexStart",
|
|
72
|
+
scale: "xs",
|
|
73
|
+
children: [props.hintIcon && jsxRuntime.jsx(Inline__default['default'], {
|
|
74
|
+
children: /*#__PURE__*/react.cloneElement(props.hintIcon, {
|
|
75
|
+
// FIXME: add proper tone when tones are refactored
|
|
76
|
+
size: 'medium',
|
|
77
|
+
color: props.hintIcon.props.color || 'warning'
|
|
78
|
+
})
|
|
79
|
+
}), props.hint && jsxRuntime.jsx(Text__default['default'].Detail, {
|
|
80
|
+
tone: props.tone,
|
|
81
|
+
children: props.hint
|
|
82
|
+
})]
|
|
83
|
+
}), props.description && jsxRuntime.jsx(Text__default['default'].Wrap, {
|
|
84
|
+
children: jsxRuntime.jsx(Text__default['default'].Detail, {
|
|
85
|
+
tone: props.tone,
|
|
86
|
+
children: props.description
|
|
87
|
+
})
|
|
88
|
+
}), props.badge && jsxRuntime.jsx("div", {
|
|
89
|
+
css: _ref,
|
|
90
|
+
children: props.badge
|
|
91
|
+
})]
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
FieldLabel.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
97
|
+
title: _pt__default['default'].oneOfType([_pt__default['default'].string, _pt__default['default'].node]).isRequired,
|
|
98
|
+
hint: _pt__default['default'].oneOfType([_pt__default['default'].string, _pt__default['default'].node]),
|
|
99
|
+
description: _pt__default['default'].oneOfType([_pt__default['default'].string, _pt__default['default'].node]),
|
|
100
|
+
onInfoButtonClick: _pt__default['default'].func,
|
|
101
|
+
tone: _pt__default['default'].oneOf(['primary', 'inverted']),
|
|
102
|
+
hintIcon: _pt__default['default'].element,
|
|
103
|
+
badge: _pt__default['default'].node,
|
|
104
|
+
hasRequiredIndicator: _pt__default['default'].bool,
|
|
105
|
+
htmlFor: _pt__default['default'].string,
|
|
106
|
+
id: _pt__default['default'].string,
|
|
107
|
+
horizontalConstraint: _pt__default['default'].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'])
|
|
108
|
+
} : {};
|
|
109
|
+
FieldLabel.displayName = 'FieldLabel';
|
|
110
|
+
FieldLabel.defaultProps = {
|
|
111
|
+
horizontalConstraint: 'scale'
|
|
112
|
+
};
|
|
113
|
+
var FieldLabel$1 = FieldLabel;
|
|
114
|
+
|
|
115
|
+
// NOTE: This string will be replaced in the `prepare` script by the `scripts/version.js` file.
|
|
116
|
+
var version = '0.0.0-canary-2021830134526';
|
|
117
|
+
|
|
118
|
+
exports['default'] = FieldLabel$1;
|
|
119
|
+
exports.version = version;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('prop-types');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
require('@commercetools-uikit/utils');
|
|
8
|
+
require('@emotion/react');
|
|
9
|
+
var IconButton = require('@commercetools-uikit/icon-button');
|
|
10
|
+
var icons = require('@commercetools-uikit/icons');
|
|
11
|
+
var Text = require('@commercetools-uikit/text');
|
|
12
|
+
var Constraints = require('@commercetools-uikit/constraints');
|
|
13
|
+
var Stack = require('@commercetools-uikit/spacings-stack');
|
|
14
|
+
var Inline = require('@commercetools-uikit/spacings-inline');
|
|
15
|
+
var Label = require('@commercetools-uikit/label');
|
|
16
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
17
|
+
|
|
18
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var IconButton__default = /*#__PURE__*/_interopDefault(IconButton);
|
|
21
|
+
var Text__default = /*#__PURE__*/_interopDefault(Text);
|
|
22
|
+
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
23
|
+
var Stack__default = /*#__PURE__*/_interopDefault(Stack);
|
|
24
|
+
var Inline__default = /*#__PURE__*/_interopDefault(Inline);
|
|
25
|
+
var Label__default = /*#__PURE__*/_interopDefault(Label);
|
|
26
|
+
|
|
27
|
+
var _ref = {
|
|
28
|
+
name: "skgbeu",
|
|
29
|
+
styles: "display:flex;justify-content:flex-end"
|
|
30
|
+
} ;
|
|
31
|
+
|
|
32
|
+
var FieldLabel = function FieldLabel(props) {
|
|
33
|
+
if (props.hintIcon) ;
|
|
34
|
+
|
|
35
|
+
return jsxRuntime.jsx(Constraints__default['default'].Horizontal, {
|
|
36
|
+
max: props.horizontalConstraint,
|
|
37
|
+
children: jsxRuntime.jsxs(Stack__default['default'], {
|
|
38
|
+
scale: "xs",
|
|
39
|
+
children: [jsxRuntime.jsxs(Inline__default['default'], {
|
|
40
|
+
alignItems: "flexStart",
|
|
41
|
+
scale: "xs",
|
|
42
|
+
children: [jsxRuntime.jsx(Text__default['default'].Wrap, {
|
|
43
|
+
children: jsxRuntime.jsx(Label__default['default'], {
|
|
44
|
+
isBold: true,
|
|
45
|
+
isRequiredIndicatorVisible: props.hasRequiredIndicator,
|
|
46
|
+
tone: props.tone,
|
|
47
|
+
id: props.id,
|
|
48
|
+
htmlFor: props.htmlFor,
|
|
49
|
+
children: props.title
|
|
50
|
+
})
|
|
51
|
+
}), props.onInfoButtonClick && jsxRuntime.jsx(IconButton__default['default'], {
|
|
52
|
+
label: "More Info",
|
|
53
|
+
icon: jsxRuntime.jsx(icons.InformationIcon, {
|
|
54
|
+
size: "medium"
|
|
55
|
+
}),
|
|
56
|
+
size: "small",
|
|
57
|
+
onClick: props.onInfoButtonClick
|
|
58
|
+
})]
|
|
59
|
+
}), props.hint && jsxRuntime.jsxs(Inline__default['default'], {
|
|
60
|
+
alignItems: "flexStart",
|
|
61
|
+
scale: "xs",
|
|
62
|
+
children: [props.hintIcon && jsxRuntime.jsx(Inline__default['default'], {
|
|
63
|
+
children: /*#__PURE__*/react.cloneElement(props.hintIcon, {
|
|
64
|
+
// FIXME: add proper tone when tones are refactored
|
|
65
|
+
size: 'medium',
|
|
66
|
+
color: props.hintIcon.props.color || 'warning'
|
|
67
|
+
})
|
|
68
|
+
}), props.hint && jsxRuntime.jsx(Text__default['default'].Detail, {
|
|
69
|
+
tone: props.tone,
|
|
70
|
+
children: props.hint
|
|
71
|
+
})]
|
|
72
|
+
}), props.description && jsxRuntime.jsx(Text__default['default'].Wrap, {
|
|
73
|
+
children: jsxRuntime.jsx(Text__default['default'].Detail, {
|
|
74
|
+
tone: props.tone,
|
|
75
|
+
children: props.description
|
|
76
|
+
})
|
|
77
|
+
}), props.badge && jsxRuntime.jsx("div", {
|
|
78
|
+
css: _ref,
|
|
79
|
+
children: props.badge
|
|
80
|
+
})]
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
FieldLabel.propTypes = {};
|
|
86
|
+
FieldLabel.displayName = 'FieldLabel';
|
|
87
|
+
FieldLabel.defaultProps = {
|
|
88
|
+
horizontalConstraint: 'scale'
|
|
89
|
+
};
|
|
90
|
+
var FieldLabel$1 = FieldLabel;
|
|
91
|
+
|
|
92
|
+
// NOTE: This string will be replaced in the `prepare` script by the `scripts/version.js` file.
|
|
93
|
+
var version = '0.0.0-canary-2021830134526';
|
|
94
|
+
|
|
95
|
+
exports['default'] = FieldLabel$1;
|
|
96
|
+
exports.version = version;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import _pt from 'prop-types';
|
|
2
|
+
import { cloneElement } from 'react';
|
|
3
|
+
import { warning } from '@commercetools-uikit/utils';
|
|
4
|
+
import '@emotion/react';
|
|
5
|
+
import IconButton from '@commercetools-uikit/icon-button';
|
|
6
|
+
import { InformationIcon } from '@commercetools-uikit/icons';
|
|
7
|
+
import Text from '@commercetools-uikit/text';
|
|
8
|
+
import Constraints from '@commercetools-uikit/constraints';
|
|
9
|
+
import Stack from '@commercetools-uikit/spacings-stack';
|
|
10
|
+
import Inline from '@commercetools-uikit/spacings-inline';
|
|
11
|
+
import Label from '@commercetools-uikit/label';
|
|
12
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
15
|
+
|
|
16
|
+
var _ref = process.env.NODE_ENV === "production" ? {
|
|
17
|
+
name: "skgbeu",
|
|
18
|
+
styles: "display:flex;justify-content:flex-end"
|
|
19
|
+
} : {
|
|
20
|
+
name: "pfzph7-FieldLabel",
|
|
21
|
+
styles: "display:flex;justify-content:flex-end;label:FieldLabel;",
|
|
22
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZpZWxkLWxhYmVsLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFnSm9CIiwiZmlsZSI6ImZpZWxkLWxhYmVsLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7XG4gIGNsb25lRWxlbWVudCxcbiAgTW91c2VFdmVudCxcbiAgS2V5Ym9hcmRFdmVudCxcbiAgUmVhY3RFbGVtZW50LFxuICBSZWFjdE5vZGUsXG59IGZyb20gJ3JlYWN0JztcbmltcG9ydCB7IHdhcm5pbmcgfSBmcm9tICdAY29tbWVyY2V0b29scy11aWtpdC91dGlscyc7XG5pbXBvcnQgeyBjc3MgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5pbXBvcnQgSWNvbkJ1dHRvbiBmcm9tICdAY29tbWVyY2V0b29scy11aWtpdC9pY29uLWJ1dHRvbic7XG5pbXBvcnQgeyBJbmZvcm1hdGlvbkljb24gfSBmcm9tICdAY29tbWVyY2V0b29scy11aWtpdC9pY29ucyc7XG5pbXBvcnQgVGV4dCBmcm9tICdAY29tbWVyY2V0b29scy11aWtpdC90ZXh0JztcbmltcG9ydCBDb25zdHJhaW50cyBmcm9tICdAY29tbWVyY2V0b29scy11aWtpdC9jb25zdHJhaW50cyc7XG5pbXBvcnQgU3RhY2sgZnJvbSAnQGNvbW1lcmNldG9vbHMtdWlraXQvc3BhY2luZ3Mtc3RhY2snO1xuaW1wb3J0IElubGluZSBmcm9tICdAY29tbWVyY2V0b29scy11aWtpdC9zcG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TGFiZWxcbiAgICAgICAgICAgICAgaXNCb2xkPXt0cnVlfVxuICAgICAgICAgICAgICBpc1JlcXVpcmVkSW5kaWNhdG9yVmlzaWJsZT17cHJvcHMuaGFzUmVxdWlyZWRJbmRpY2F0b3J9XG4gICAgICAgICAgICAgIHRvbmU9e3Byb3BzLnRvbmV9XG4gICAgICAgICAgICAgIGlkPXtwcm9wcy5pZH1cbiAgICAgICAgICAgICAgaHRtbEZvcj17cHJvcHMuaHRtbEZvcn1cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAge3Byb3BzLnRpdGxlfVxuICAgICAgICAgICAgPC9MYWJlbD5cbiAgICAgICAgICA8L1RleHQuV3JhcD5cbiAgICAgICAgICB7cHJvcHMub25JbmZvQnV0dG9uQ2xpY2sgJiYgKFxuICAgICAgICAgICAgPEljb25CdXR0b25cbiAgICAgICAgICAgICAgbGFiZWw9XCJNb3JlIEluZm9cIlxuICAgICAgICAgICAgICBpY29uPXs8SW5mb3JtYXRpb25JY29uIHNpemU9XCJtZWRpdW1cIiAvPn1cbiAgICAgICAgICAgICAgc2l6ZT1cInNtYWxsXCJcbiAgICAgICAgICAgICAgb25DbGljaz17cHJvcHMub25JbmZvQnV0dG9uQ2xpY2t9XG4gICAgICAgICAgICAvPlxuICAgICAgICAgICl9XG4gICAgICAgIDwvSW5saW5lPlxuXG4gICAgICAgIHtwcm9wcy5oaW50ICYmIChcbiAgICAgICAgICA8SW5saW5lIGFsaWduSXRlbXM9XCJmbGV4U3RhcnRcIiBzY2FsZT1cInhzXCI+XG4gICAgICAgICAgICB7cHJvcHMuaGludEljb24gJiYgKFxuICAgICAgICAgICAgICA8SW5saW5lPlxuICAgICAgICAgICAgICAgIHtjbG9uZUVsZW1lbnQocHJvcHMuaGludEljb24sIHtcbiAgICAgICAgICAgICAgICAgIC8vIEZJWE1FOiBhZGQgcHJvcGVyIHRvbmUgd2hlbiB0b25lcyBhcmUgcmVmYWN0b3JlZFxuICAgICAgICAgICAgICAgICAgc2l6ZTogJ21lZGl1bScsXG4gICAgICAgICAgICAgICAgICBjb2xvcjogcHJvcHMuaGludEljb24ucHJvcHMuY29sb3IgfHwgJ3dhcm5pbmcnLFxuICAgICAgICAgICAgICAgIH0pfVxuICAgICAgICAgICAgICA8L0lubGluZT5cbiAgICAgICAgICAgICl9XG4gICAgICAgICAgICB7cHJvcHMuaGludCAmJiAoXG4gICAgICAgICAgICAgIDxUZXh0LkRldGFpbCB0b25lPXtwcm9wcy50b25lfT57cHJvcHMuaGludH08L1RleHQuRGV0YWlsPlxuICAgICAgICAgICAgKX1cbiAgICAgICAgICA8L0lubGluZT5cbiAgICAgICAgKX1cbiAgICAgICAge3Byb3BzLmRlc2NyaXB0aW9uICYmIChcbiAgICAgICAgICA8VGV4dC5XcmFwPlxuICAgICAgICAgICAgPFRleHQuRGV0YWlsIHRvbmU9e3Byb3BzLnRvbmV9Pntwcm9wcy5kZXNjcmlwdGlvbn08L1RleHQuRGV0YWlsPlxuICAgICAgICAgIDwvVGV4dC5XcmFwPlxuICAgICAgICApfVxuXG4gICAgICAgIHtwcm9wcy5iYWRnZSAmJiAoXG4gICAgICAgICAgPGRpdlxuICAgICAgICAgICAgY3NzPXtjc3NgXG4gICAgICAgICAgICAgIGRpc3BsYXk6IGZsZXg7XG4gICAgICAgICAgICAgIGp1c3RpZnktY29udGVudDogZmxleC1lbmQ7XG4gICAgICAgICAgICBgfVxuICAgICAgICAgID5cbiAgICAgICAgICAgIHtwcm9wcy5iYWRnZX1cbiAgICAgICAgICA8L2Rpdj5cbiAgICAgICAgKX1cbiAgICAgIDwvU3RhY2s+XG4gICAgPC9Db25zdHJhaW50cy5Ib3Jpem9udGFsPlxuICApO1xufTtcblxuRmllbGRMYWJlbC5kaXNwbGF5TmFtZSA9ICdGaWVsZExhYmVsJztcbkZpZWxkTGFiZWwuZGVmYXVsdFByb3BzID0ge1xuICBob3Jpem9udGFsQ29uc3RyYWludDogJ3NjYWxlJyxcbn07XG5cbmV4cG9ydCBkZWZhdWx0IEZpZWxkTGFiZWw7XG4iXX0= */",
|
|
23
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var FieldLabel = function FieldLabel(props) {
|
|
27
|
+
if (props.hintIcon) {
|
|
28
|
+
process.env.NODE_ENV !== "production" ? warning(props.hintIcon.props.size === undefined, 'ui-kit/FieldLabel: setting `hintIcon` size is not supported.') : void 0;
|
|
29
|
+
process.env.NODE_ENV !== "production" ? warning(Boolean(props.hint), 'ui-kit/FieldLabel: `hint` is required when `hintIcon` is provided') : void 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return jsx(Constraints.Horizontal, {
|
|
33
|
+
max: props.horizontalConstraint,
|
|
34
|
+
children: jsxs(Stack, {
|
|
35
|
+
scale: "xs",
|
|
36
|
+
children: [jsxs(Inline, {
|
|
37
|
+
alignItems: "flexStart",
|
|
38
|
+
scale: "xs",
|
|
39
|
+
children: [jsx(Text.Wrap, {
|
|
40
|
+
children: jsx(Label, {
|
|
41
|
+
isBold: true,
|
|
42
|
+
isRequiredIndicatorVisible: props.hasRequiredIndicator,
|
|
43
|
+
tone: props.tone,
|
|
44
|
+
id: props.id,
|
|
45
|
+
htmlFor: props.htmlFor,
|
|
46
|
+
children: props.title
|
|
47
|
+
})
|
|
48
|
+
}), props.onInfoButtonClick && jsx(IconButton, {
|
|
49
|
+
label: "More Info",
|
|
50
|
+
icon: jsx(InformationIcon, {
|
|
51
|
+
size: "medium"
|
|
52
|
+
}),
|
|
53
|
+
size: "small",
|
|
54
|
+
onClick: props.onInfoButtonClick
|
|
55
|
+
})]
|
|
56
|
+
}), props.hint && jsxs(Inline, {
|
|
57
|
+
alignItems: "flexStart",
|
|
58
|
+
scale: "xs",
|
|
59
|
+
children: [props.hintIcon && jsx(Inline, {
|
|
60
|
+
children: /*#__PURE__*/cloneElement(props.hintIcon, {
|
|
61
|
+
// FIXME: add proper tone when tones are refactored
|
|
62
|
+
size: 'medium',
|
|
63
|
+
color: props.hintIcon.props.color || 'warning'
|
|
64
|
+
})
|
|
65
|
+
}), props.hint && jsx(Text.Detail, {
|
|
66
|
+
tone: props.tone,
|
|
67
|
+
children: props.hint
|
|
68
|
+
})]
|
|
69
|
+
}), props.description && jsx(Text.Wrap, {
|
|
70
|
+
children: jsx(Text.Detail, {
|
|
71
|
+
tone: props.tone,
|
|
72
|
+
children: props.description
|
|
73
|
+
})
|
|
74
|
+
}), props.badge && jsx("div", {
|
|
75
|
+
css: _ref,
|
|
76
|
+
children: props.badge
|
|
77
|
+
})]
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
FieldLabel.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
83
|
+
title: _pt.oneOfType([_pt.string, _pt.node]).isRequired,
|
|
84
|
+
hint: _pt.oneOfType([_pt.string, _pt.node]),
|
|
85
|
+
description: _pt.oneOfType([_pt.string, _pt.node]),
|
|
86
|
+
onInfoButtonClick: _pt.func,
|
|
87
|
+
tone: _pt.oneOf(['primary', 'inverted']),
|
|
88
|
+
hintIcon: _pt.element,
|
|
89
|
+
badge: _pt.node,
|
|
90
|
+
hasRequiredIndicator: _pt.bool,
|
|
91
|
+
htmlFor: _pt.string,
|
|
92
|
+
id: _pt.string,
|
|
93
|
+
horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'])
|
|
94
|
+
} : {};
|
|
95
|
+
FieldLabel.displayName = 'FieldLabel';
|
|
96
|
+
FieldLabel.defaultProps = {
|
|
97
|
+
horizontalConstraint: 'scale'
|
|
98
|
+
};
|
|
99
|
+
var FieldLabel$1 = FieldLabel;
|
|
100
|
+
|
|
101
|
+
// NOTE: This string will be replaced in the `prepare` script by the `scripts/version.js` file.
|
|
102
|
+
var version = '0.0.0-canary-2021830134526';
|
|
103
|
+
|
|
104
|
+
export { FieldLabel$1 as default, version };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MouseEvent, KeyboardEvent, ReactElement, ReactNode } from 'react';
|
|
2
|
+
export declare type TFieldLabelProps = {
|
|
3
|
+
title: string | ReactNode;
|
|
4
|
+
hint?: string | ReactNode;
|
|
5
|
+
description?: string | ReactNode;
|
|
6
|
+
onInfoButtonClick?: (event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void;
|
|
7
|
+
tone?: 'primary' | 'inverted';
|
|
8
|
+
hintIcon?: ReactElement;
|
|
9
|
+
badge?: ReactNode;
|
|
10
|
+
hasRequiredIndicator?: boolean;
|
|
11
|
+
htmlFor?: string;
|
|
12
|
+
id?: string;
|
|
13
|
+
horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
14
|
+
};
|
|
15
|
+
declare const FieldLabel: {
|
|
16
|
+
(props: TFieldLabelProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
17
|
+
displayName: string;
|
|
18
|
+
defaultProps: {
|
|
19
|
+
horizontalConstraint: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default FieldLabel;
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@commercetools-uikit/field-label",
|
|
3
|
+
"description": "The FieldLabel component represents the label for a field in a form.",
|
|
4
|
+
"version": "0.0.0-canary-2021830134526",
|
|
5
|
+
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/commercetools/ui-kit.git",
|
|
9
|
+
"directory": "packages/components/field-label"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://uikit.commercetools.com",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"javascript",
|
|
14
|
+
"design system",
|
|
15
|
+
"react",
|
|
16
|
+
"uikit"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"private": false,
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"main": "dist/commercetools-uikit-field-label.cjs.js",
|
|
25
|
+
"module": "dist/commercetools-uikit-field-label.esm.js",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"prepare": "../../../scripts/version.js replace"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@babel/runtime": "7.14.8",
|
|
34
|
+
"@babel/runtime-corejs3": "7.14.9",
|
|
35
|
+
"@commercetools-uikit/constraints": "0.0.0-canary-2021830134526",
|
|
36
|
+
"@commercetools-uikit/icon-button": "0.0.0-canary-2021830134526",
|
|
37
|
+
"@commercetools-uikit/icons": "0.0.0-canary-2021830134526",
|
|
38
|
+
"@commercetools-uikit/label": "0.0.0-canary-2021830134526",
|
|
39
|
+
"@commercetools-uikit/spacings-inline": "0.0.0-canary-2021830134526",
|
|
40
|
+
"@commercetools-uikit/spacings-stack": "0.0.0-canary-2021830134526",
|
|
41
|
+
"@commercetools-uikit/text": "0.0.0-canary-2021830134526",
|
|
42
|
+
"@commercetools-uikit/utils": "12.2.0",
|
|
43
|
+
"@emotion/react": "^11.4.0",
|
|
44
|
+
"@emotion/styled": "^11.3.0",
|
|
45
|
+
"prop-types": "15.7.2",
|
|
46
|
+
"react-required-if": "1.0.3"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"react": "17.0.2"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"react": "17.x"
|
|
53
|
+
}
|
|
54
|
+
}
|