@progress/kendo-react-labels 6.1.1 → 7.0.0-develop.1

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.
Files changed (42) hide show
  1. package/{dist/es/Error.d.ts → Error.d.ts} +5 -1
  2. package/{dist/npm/FloatingLabel.d.ts → FloatingLabel.d.ts} +5 -1
  3. package/{dist/es/Hint.d.ts → Hint.d.ts} +5 -1
  4. package/LICENSE.md +1 -1
  5. package/{dist/es/Label.d.ts → Label.d.ts} +5 -1
  6. package/dist/cdn/js/kendo-react-labels.js +5 -1
  7. package/index.d.ts +9 -0
  8. package/index.js +5 -0
  9. package/index.mjs +203 -0
  10. package/messages/index.d.ts +14 -0
  11. package/package-metadata.d.ts +9 -0
  12. package/package.json +27 -40
  13. package/about.md +0 -3
  14. package/dist/es/Error.js +0 -41
  15. package/dist/es/FloatingLabel.d.ts +0 -123
  16. package/dist/es/FloatingLabel.js +0 -124
  17. package/dist/es/Hint.js +0 -43
  18. package/dist/es/Label.js +0 -81
  19. package/dist/es/main.d.ts +0 -5
  20. package/dist/es/main.js +0 -5
  21. package/dist/es/messages/index.d.ts +0 -10
  22. package/dist/es/messages/index.js +0 -11
  23. package/dist/es/package-metadata.d.ts +0 -5
  24. package/dist/es/package-metadata.js +0 -11
  25. package/dist/npm/Error.d.ts +0 -47
  26. package/dist/npm/Error.js +0 -45
  27. package/dist/npm/FloatingLabel.js +0 -127
  28. package/dist/npm/Hint.d.ts +0 -52
  29. package/dist/npm/Hint.js +0 -47
  30. package/dist/npm/Label.d.ts +0 -95
  31. package/dist/npm/Label.js +0 -85
  32. package/dist/npm/main.d.ts +0 -5
  33. package/dist/npm/main.js +0 -11
  34. package/dist/npm/messages/index.d.ts +0 -10
  35. package/dist/npm/messages/index.js +0 -14
  36. package/dist/npm/package-metadata.d.ts +0 -5
  37. package/dist/npm/package-metadata.js +0 -14
  38. package/dist/systemjs/kendo-react-labels.js +0 -1
  39. package/e2e-next/error.basic.tests.ts +0 -23
  40. package/e2e-next/floatinglabel.basic.tests.ts +0 -24
  41. package/e2e-next/hint.basic.tests.ts +0 -23
  42. package/e2e-next/label.basic.tests.ts +0 -24
@@ -1,123 +0,0 @@
1
- import * as React from 'react';
2
- import * as PropTypes from 'prop-types';
3
- import { KendoReactComponentBaseProps } from '@progress/kendo-react-common';
4
- /**
5
- * Represents the props of the KendoReact FloatingLabel component.
6
- */
7
- export interface FloatingLabelProps extends KendoReactComponentBaseProps {
8
- /**
9
- * Represent the [`htmlFor`](https://reactjs.org/docs/dom-elements.html#htmlfor) property, which will be set to the `label` element.
10
- */
11
- editorId?: string;
12
- /**
13
- * Specifies the value of the editor. Used to define if the editor is empty.
14
- */
15
- editorValue?: any;
16
- /**
17
- * Specifies the placeholder of the editor. Used to define if the editor is empty.
18
- */
19
- editorPlaceholder?: string;
20
- /**
21
- * Specifies if the validity of the editor. Used to define the editor is invalid.
22
- */
23
- editorValid?: boolean;
24
- /**
25
- * Specifies if the editor is disabled.
26
- */
27
- editorDisabled?: boolean;
28
- /**
29
- * Adds a floating label that describes the editor.
30
- */
31
- label?: string;
32
- /**
33
- * The styles that are applied to the FloatingLabel.
34
- */
35
- style?: React.CSSProperties;
36
- /**
37
- * Sets a class of the FloatingLabel DOM element.
38
- */
39
- className?: string;
40
- /**
41
- * Sets the `className` of the label DOM element.
42
- */
43
- labelClassName?: string;
44
- /**
45
- * Specifies the direction of the label.
46
- */
47
- dir?: string;
48
- /**
49
- * Represents the id of the label element.
50
- * The value should be also set to the editor's `ariaLabelledBy` property.
51
- * Can be used when the editor is not containing native form element.
52
- */
53
- id?: string;
54
- /**
55
- * If enabled, marks the label as optional.
56
- */
57
- optional?: boolean;
58
- }
59
- /**
60
- * @hidden
61
- */
62
- export interface FloatingLabelState {
63
- focused?: boolean;
64
- }
65
- /**
66
- * Represents the KendoReact FloatingLabel component.
67
- *
68
- * @example
69
- * ```jsx
70
- * const sizes = ["X-Small", "Small", "Medium", "Large", "X-Large", "2X-Large"];
71
- * const App = () => {
72
- * const [ddlState, setDdlState] = React.useState();
73
- * const editorId = 'ddl-sizes';
74
- * return (
75
- * <FloatingLabel label={'Shirt Size:'} editorId={editorId} editorValue={ddlState}>
76
- * <DropDownList
77
- * id={editorId}
78
- * value={ddlState}
79
- * data={sizes}
80
- * onChange={(e) => setDdlState(e.target.value)}
81
- * />
82
- * </FloatingLabel>
83
- * );
84
- * };
85
- *
86
- * ReactDOM.render(<App />, document.querySelector('my-app'));
87
- * ```
88
- */
89
- export declare class FloatingLabel extends React.Component<FloatingLabelProps, FloatingLabelState> {
90
- /**
91
- * @hidden
92
- */
93
- static propTypes: {
94
- label: PropTypes.Requireable<string>;
95
- editorId: PropTypes.Requireable<string>;
96
- editorValue: PropTypes.Requireable<NonNullable<string | number | boolean | null | undefined>>;
97
- editorPlaceholder: PropTypes.Requireable<string>;
98
- editorValid: PropTypes.Requireable<boolean>;
99
- editorDisabled: PropTypes.Requireable<boolean>;
100
- id: PropTypes.Requireable<string>;
101
- style: PropTypes.Requireable<object>;
102
- className: PropTypes.Requireable<string>;
103
- labelClassName: PropTypes.Requireable<string>;
104
- optional: PropTypes.Requireable<boolean>;
105
- };
106
- /**
107
- * @hidden
108
- */
109
- readonly state: FloatingLabelState;
110
- constructor(props: FloatingLabelProps);
111
- /**
112
- * @hidden
113
- */
114
- handleFocus: (_: React.SyntheticEvent<HTMLSpanElement>) => void;
115
- /**
116
- * @hidden
117
- */
118
- handleBlur: (_: React.SyntheticEvent<HTMLSpanElement>) => void;
119
- /**
120
- * @hidden
121
- */
122
- render(): JSX.Element;
123
- }
@@ -1,124 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- import * as React from 'react';
17
- import * as PropTypes from 'prop-types';
18
- import { classNames } from '@progress/kendo-react-common';
19
- import { provideLocalizationService, registerForLocalization } from '@progress/kendo-react-intl';
20
- import { labelsOptional, messages } from './messages';
21
- import { validatePackage } from '@progress/kendo-react-common';
22
- import { packageMetadata } from './package-metadata';
23
- /**
24
- * Represents the KendoReact FloatingLabel component.
25
- *
26
- * @example
27
- * ```jsx
28
- * const sizes = ["X-Small", "Small", "Medium", "Large", "X-Large", "2X-Large"];
29
- * const App = () => {
30
- * const [ddlState, setDdlState] = React.useState();
31
- * const editorId = 'ddl-sizes';
32
- * return (
33
- * <FloatingLabel label={'Shirt Size:'} editorId={editorId} editorValue={ddlState}>
34
- * <DropDownList
35
- * id={editorId}
36
- * value={ddlState}
37
- * data={sizes}
38
- * onChange={(e) => setDdlState(e.target.value)}
39
- * />
40
- * </FloatingLabel>
41
- * );
42
- * };
43
- *
44
- * ReactDOM.render(<App />, document.querySelector('my-app'));
45
- * ```
46
- */
47
- var FloatingLabel = /** @class */ (function (_super) {
48
- __extends(FloatingLabel, _super);
49
- function FloatingLabel(props) {
50
- var _this = _super.call(this, props) || this;
51
- /**
52
- * @hidden
53
- */
54
- _this.state = {
55
- focused: false
56
- };
57
- /**
58
- * @hidden
59
- */
60
- _this.handleFocus = function (_) {
61
- _this.setState({ focused: true });
62
- };
63
- /**
64
- * @hidden
65
- */
66
- _this.handleBlur = function (_) {
67
- _this.setState({ focused: false });
68
- };
69
- validatePackage(packageMetadata);
70
- return _this;
71
- }
72
- /**
73
- * @hidden
74
- */
75
- FloatingLabel.prototype.render = function () {
76
- var _a = this.props, label = _a.label, editorId = _a.editorId, className = _a.className, labelClassName = _a.labelClassName, editorValue = _a.editorValue, editorPlaceholder = _a.editorPlaceholder, editorValid = _a.editorValid, editorDisabled = _a.editorDisabled, style = _a.style, id = _a.id, optional = _a.optional;
77
- var localizationService = provideLocalizationService(this);
78
- var localizedOptional = optional ? localizationService
79
- .toLanguageString(labelsOptional, messages[labelsOptional]) : '';
80
- var optionalElement = localizedOptional && (React.createElement("span", { className: 'k-label-optional' }, localizedOptional));
81
- var spanClassNames = classNames({
82
- 'k-floating-label-container': true,
83
- 'k-focus': this.state.focused,
84
- 'k-empty': !editorPlaceholder && !editorValue && (editorValue !== 0),
85
- 'k-text-disabled': editorDisabled,
86
- 'k-rtl': this.props.dir === 'rtl'
87
- }, className);
88
- var labelClassNames = classNames({
89
- 'k-label': true,
90
- 'k-text-error': editorValid === false,
91
- 'k-text-disabled': editorDisabled
92
- }, labelClassName);
93
- return (React.createElement("span", { id: this.props.id, className: spanClassNames, onFocus: this.handleFocus, onBlur: this.handleBlur, style: style, dir: this.props.dir },
94
- this.props.children,
95
- label
96
- ? editorId
97
- ? React.createElement("label", { id: id, htmlFor: editorId, className: labelClassNames },
98
- label,
99
- optionalElement)
100
- : React.createElement("span", { id: id, className: labelClassNames },
101
- label,
102
- optionalElement)
103
- : null));
104
- };
105
- /**
106
- * @hidden
107
- */
108
- FloatingLabel.propTypes = {
109
- label: PropTypes.string,
110
- editorId: PropTypes.string,
111
- editorValue: PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number]),
112
- editorPlaceholder: PropTypes.string,
113
- editorValid: PropTypes.bool,
114
- editorDisabled: PropTypes.bool,
115
- id: PropTypes.string,
116
- style: PropTypes.object,
117
- className: PropTypes.string,
118
- labelClassName: PropTypes.string,
119
- optional: PropTypes.bool
120
- };
121
- return FloatingLabel;
122
- }(React.Component));
123
- export { FloatingLabel };
124
- registerForLocalization(FloatingLabel);
package/dist/es/Hint.js DELETED
@@ -1,43 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import * as React from 'react';
13
- import * as PropTypes from 'prop-types';
14
- import { classNames } from '@progress/kendo-react-common';
15
- import { validatePackage } from '@progress/kendo-react-common';
16
- import { packageMetadata } from './package-metadata';
17
- /**
18
- * Represents the KendoReact Hint component.
19
- * Render the hint text that will be shown underneath the form editor.
20
- */
21
- export var Hint = function (props) {
22
- var combinedProps = __assign({ direction: 'start' }, props);
23
- validatePackage(packageMetadata);
24
- var hintClassName = classNames({
25
- 'k-form-hint': true,
26
- 'k-text-start': combinedProps.direction === 'start',
27
- 'k-text-end': combinedProps.direction === 'end',
28
- 'k-text-disabled': combinedProps.editorDisabled === true
29
- }, combinedProps.className);
30
- return (React.createElement("div", { id: combinedProps.id, style: combinedProps.style, className: hintClassName }, combinedProps.children));
31
- };
32
- Hint.propTypes = {
33
- id: PropTypes.string,
34
- direction: PropTypes.oneOf(['start', 'end']),
35
- children: PropTypes.oneOfType([
36
- PropTypes.element,
37
- PropTypes.node
38
- ]),
39
- style: PropTypes.object,
40
- className: PropTypes.string,
41
- editorDisabled: PropTypes.bool
42
- };
43
- Hint.displayName = 'KendoReactHint';
package/dist/es/Label.js DELETED
@@ -1,81 +0,0 @@
1
- import * as React from 'react';
2
- import * as PropTypes from 'prop-types';
3
- import { classNames } from '@progress/kendo-react-common';
4
- import { labelsOptional, messages } from './messages';
5
- import { useLocalization } from '@progress/kendo-react-intl';
6
- import { validatePackage } from '@progress/kendo-react-common';
7
- import { packageMetadata } from './package-metadata';
8
- /**
9
- * Represents the KendoReact Label component.
10
- *
11
- * @example
12
- * ```jsx
13
- * const sizes = ["X-Small", "Small", "Medium", "Large", "X-Large", "2X-Large"];
14
- * const App = () => {
15
- * const ddlRef = React.useRef(null);
16
- * const labelId = 'ddl-sizes-label';
17
- * const editorId = 'ddl-sizes';
18
- *
19
- * return (
20
- * <div>
21
- * <Label id={labelId} editorId={editorId} editorRef={ddlRef}>
22
- * Shirt Size:
23
- * </Label>
24
- * <DropDownList
25
- * ref={ddlRef}
26
- * id={editorId}
27
- * ariaLabelledBy={labelId}
28
- * data={sizes}
29
- * />
30
- * <br />
31
- * </div>
32
- * );
33
- * };
34
- *
35
- * ReactDOM.render(<App />, document.querySelector('my-app'));
36
- * ```
37
- */
38
- export var Label = function (props) {
39
- validatePackage(packageMetadata);
40
- var id = props.id, editorId = props.editorId, editorRef = props.editorRef, editorDisabled = props.editorDisabled, children = props.children, editorValid = props.editorValid, style = props.style, className = props.className, optional = props.optional;
41
- var localizationService = useLocalization();
42
- var localizedOptional = optional ? localizationService
43
- .toLanguageString(labelsOptional, messages[labelsOptional]) : '';
44
- var optionalElement = localizedOptional && (React.createElement("span", { className: 'k-label-optional' }, localizedOptional));
45
- var onLabelClick = React.useCallback(function (e) {
46
- if (editorRef && editorRef.current && !editorDisabled) {
47
- if (editorRef.current.focus) {
48
- e.preventDefault();
49
- editorRef.current.focus();
50
- }
51
- var editorActionElement = editorRef.current.actionElement;
52
- if (editorActionElement) {
53
- e.preventDefault();
54
- editorActionElement.click();
55
- }
56
- }
57
- }, [editorRef]);
58
- var labelClassName = classNames({
59
- 'k-label': true,
60
- 'k-label-empty': !children,
61
- 'k-text-error': editorValid === false,
62
- 'k-text-disabled': editorDisabled === true
63
- }, className);
64
- return (React.createElement("label", { id: id, htmlFor: editorId, onClick: onLabelClick, style: style, className: labelClassName },
65
- children,
66
- optionalElement));
67
- };
68
- Label.propTypes = {
69
- id: PropTypes.string,
70
- editorId: PropTypes.string,
71
- editorRef: PropTypes.oneOfType([
72
- PropTypes.func,
73
- PropTypes.shape({ current: PropTypes.any })
74
- ]),
75
- editorValid: PropTypes.bool,
76
- editorDisabled: PropTypes.bool,
77
- style: PropTypes.object,
78
- className: PropTypes.string,
79
- optional: PropTypes.bool
80
- };
81
- Label.displayName = 'KendoReactLabel';
package/dist/es/main.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { Label, LabelProps } from './Label';
2
- import { Error, ErrorProps } from './Error';
3
- import { Hint, HintProps } from './Hint';
4
- import { FloatingLabel, FloatingLabelProps } from './FloatingLabel';
5
- export { FloatingLabel, FloatingLabelProps, Label, LabelProps, Error, ErrorProps, Hint, HintProps };
package/dist/es/main.js DELETED
@@ -1,5 +0,0 @@
1
- import { Label } from './Label';
2
- import { Error } from './Error';
3
- import { Hint } from './Hint';
4
- import { FloatingLabel } from './FloatingLabel';
5
- export { FloatingLabel, Label, Error, Hint };
@@ -1,10 +0,0 @@
1
- /**
2
- * @hidden
3
- */
4
- export declare const labelsOptional = "labels.optional";
5
- /**
6
- * @hidden
7
- */
8
- export declare const messages: {
9
- "labels.optional": string;
10
- };
@@ -1,11 +0,0 @@
1
- var _a;
2
- /**
3
- * @hidden
4
- */
5
- export var labelsOptional = 'labels.optional';
6
- /**
7
- * @hidden
8
- */
9
- export var messages = (_a = {},
10
- _a[labelsOptional] = '(Optional)',
11
- _a);
@@ -1,5 +0,0 @@
1
- import { PackageMetadata } from '@progress/kendo-licensing';
2
- /**
3
- * @hidden
4
- */
5
- export declare const packageMetadata: PackageMetadata;
@@ -1,11 +0,0 @@
1
- /**
2
- * @hidden
3
- */
4
- export var packageMetadata = {
5
- name: '@progress/kendo-react-labels',
6
- productName: 'KendoReact',
7
- productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
8
- publishDate: 1700063806,
9
- version: '',
10
- licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
11
- };
@@ -1,47 +0,0 @@
1
- import * as React from 'react';
2
- import * as PropTypes from 'prop-types';
3
- /**
4
- * Represents the props of the KendoReact Error component.
5
- */
6
- export interface ErrorProps {
7
- /**
8
- * Represents the id of the Error element.
9
- * The value should be also set to the editor's `ariaDescribedBy` property.
10
- */
11
- id?: string;
12
- /**
13
- * Specifies the alignment of the Error text.
14
- *
15
- * The possible values are:
16
- * * (Default) `start`
17
- * * `end`
18
- */
19
- direction?: 'start' | 'end';
20
- /**
21
- * Determines the children nodes.
22
- */
23
- children: any;
24
- /**
25
- * The styles that are applied to the Error.
26
- */
27
- style?: React.CSSProperties;
28
- /**
29
- * Sets a class of the Error DOM element.
30
- */
31
- className?: string;
32
- }
33
- /**
34
- * Represents the KendoReact Error component.
35
- * Render the error text that will be shown underneath the form editor after a validation.
36
- */
37
- export declare const Error: {
38
- (props: ErrorProps): JSX.Element;
39
- propTypes: {
40
- id: PropTypes.Requireable<string>;
41
- direction: PropTypes.Requireable<string>;
42
- children: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
43
- style: PropTypes.Requireable<object>;
44
- className: PropTypes.Requireable<string>;
45
- };
46
- displayName: string;
47
- };
package/dist/npm/Error.js DELETED
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.Error = void 0;
15
- var React = require("react");
16
- var PropTypes = require("prop-types");
17
- var kendo_react_common_1 = require("@progress/kendo-react-common");
18
- var kendo_react_common_2 = require("@progress/kendo-react-common");
19
- var package_metadata_1 = require("./package-metadata");
20
- /**
21
- * Represents the KendoReact Error component.
22
- * Render the error text that will be shown underneath the form editor after a validation.
23
- */
24
- var Error = function (props) {
25
- var combinedProps = __assign({ direction: 'start' }, props);
26
- (0, kendo_react_common_2.validatePackage)(package_metadata_1.packageMetadata);
27
- var errorClassName = (0, kendo_react_common_1.classNames)({
28
- 'k-form-error': true,
29
- 'k-text-start': combinedProps.direction === 'start',
30
- 'k-text-end': combinedProps.direction === 'end'
31
- }, combinedProps.className);
32
- return (React.createElement("div", { id: combinedProps.id, role: 'alert', style: combinedProps.style, className: errorClassName }, combinedProps.children));
33
- };
34
- exports.Error = Error;
35
- exports.Error.propTypes = {
36
- id: PropTypes.string,
37
- direction: PropTypes.oneOf(['start', 'end']),
38
- children: PropTypes.oneOfType([
39
- PropTypes.element,
40
- PropTypes.node
41
- ]),
42
- style: PropTypes.object,
43
- className: PropTypes.string
44
- };
45
- exports.Error.displayName = 'KendoReactError';
@@ -1,127 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.FloatingLabel = void 0;
19
- var React = require("react");
20
- var PropTypes = require("prop-types");
21
- var kendo_react_common_1 = require("@progress/kendo-react-common");
22
- var kendo_react_intl_1 = require("@progress/kendo-react-intl");
23
- var messages_1 = require("./messages");
24
- var kendo_react_common_2 = require("@progress/kendo-react-common");
25
- var package_metadata_1 = require("./package-metadata");
26
- /**
27
- * Represents the KendoReact FloatingLabel component.
28
- *
29
- * @example
30
- * ```jsx
31
- * const sizes = ["X-Small", "Small", "Medium", "Large", "X-Large", "2X-Large"];
32
- * const App = () => {
33
- * const [ddlState, setDdlState] = React.useState();
34
- * const editorId = 'ddl-sizes';
35
- * return (
36
- * <FloatingLabel label={'Shirt Size:'} editorId={editorId} editorValue={ddlState}>
37
- * <DropDownList
38
- * id={editorId}
39
- * value={ddlState}
40
- * data={sizes}
41
- * onChange={(e) => setDdlState(e.target.value)}
42
- * />
43
- * </FloatingLabel>
44
- * );
45
- * };
46
- *
47
- * ReactDOM.render(<App />, document.querySelector('my-app'));
48
- * ```
49
- */
50
- var FloatingLabel = /** @class */ (function (_super) {
51
- __extends(FloatingLabel, _super);
52
- function FloatingLabel(props) {
53
- var _this = _super.call(this, props) || this;
54
- /**
55
- * @hidden
56
- */
57
- _this.state = {
58
- focused: false
59
- };
60
- /**
61
- * @hidden
62
- */
63
- _this.handleFocus = function (_) {
64
- _this.setState({ focused: true });
65
- };
66
- /**
67
- * @hidden
68
- */
69
- _this.handleBlur = function (_) {
70
- _this.setState({ focused: false });
71
- };
72
- (0, kendo_react_common_2.validatePackage)(package_metadata_1.packageMetadata);
73
- return _this;
74
- }
75
- /**
76
- * @hidden
77
- */
78
- FloatingLabel.prototype.render = function () {
79
- var _a = this.props, label = _a.label, editorId = _a.editorId, className = _a.className, labelClassName = _a.labelClassName, editorValue = _a.editorValue, editorPlaceholder = _a.editorPlaceholder, editorValid = _a.editorValid, editorDisabled = _a.editorDisabled, style = _a.style, id = _a.id, optional = _a.optional;
80
- var localizationService = (0, kendo_react_intl_1.provideLocalizationService)(this);
81
- var localizedOptional = optional ? localizationService
82
- .toLanguageString(messages_1.labelsOptional, messages_1.messages[messages_1.labelsOptional]) : '';
83
- var optionalElement = localizedOptional && (React.createElement("span", { className: 'k-label-optional' }, localizedOptional));
84
- var spanClassNames = (0, kendo_react_common_1.classNames)({
85
- 'k-floating-label-container': true,
86
- 'k-focus': this.state.focused,
87
- 'k-empty': !editorPlaceholder && !editorValue && (editorValue !== 0),
88
- 'k-text-disabled': editorDisabled,
89
- 'k-rtl': this.props.dir === 'rtl'
90
- }, className);
91
- var labelClassNames = (0, kendo_react_common_1.classNames)({
92
- 'k-label': true,
93
- 'k-text-error': editorValid === false,
94
- 'k-text-disabled': editorDisabled
95
- }, labelClassName);
96
- return (React.createElement("span", { id: this.props.id, className: spanClassNames, onFocus: this.handleFocus, onBlur: this.handleBlur, style: style, dir: this.props.dir },
97
- this.props.children,
98
- label
99
- ? editorId
100
- ? React.createElement("label", { id: id, htmlFor: editorId, className: labelClassNames },
101
- label,
102
- optionalElement)
103
- : React.createElement("span", { id: id, className: labelClassNames },
104
- label,
105
- optionalElement)
106
- : null));
107
- };
108
- /**
109
- * @hidden
110
- */
111
- FloatingLabel.propTypes = {
112
- label: PropTypes.string,
113
- editorId: PropTypes.string,
114
- editorValue: PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number]),
115
- editorPlaceholder: PropTypes.string,
116
- editorValid: PropTypes.bool,
117
- editorDisabled: PropTypes.bool,
118
- id: PropTypes.string,
119
- style: PropTypes.object,
120
- className: PropTypes.string,
121
- labelClassName: PropTypes.string,
122
- optional: PropTypes.bool
123
- };
124
- return FloatingLabel;
125
- }(React.Component));
126
- exports.FloatingLabel = FloatingLabel;
127
- (0, kendo_react_intl_1.registerForLocalization)(FloatingLabel);