@webiny/ui 5.29.0 → 5.30.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.
Files changed (98) hide show
  1. package/AutoComplete/MultiAutoComplete.js +2 -0
  2. package/AutoComplete/MultiAutoComplete.js.map +1 -1
  3. package/AutoComplete/utils.d.ts +1 -1
  4. package/Button/Button.js +3 -1
  5. package/Button/Button.js.map +1 -1
  6. package/Button/Button.styles.d.ts +6 -0
  7. package/Button/Button.styles.js +15 -0
  8. package/Button/Button.styles.js.map +1 -0
  9. package/Chips/Chips.stories.js +10 -6
  10. package/Chips/Chips.stories.js.map +1 -1
  11. package/Chips/index.d.ts +0 -1
  12. package/Chips/index.js +0 -13
  13. package/Chips/index.js.map +1 -1
  14. package/Chips/styles.js +7 -5
  15. package/Chips/styles.js.map +1 -1
  16. package/Dialog/Dialog.js +4 -2
  17. package/Dialog/Dialog.js.map +1 -1
  18. package/DynamicFieldset/Fieldset.js +4 -1
  19. package/DynamicFieldset/Fieldset.js.map +1 -1
  20. package/Grid/Grid.js +1 -1
  21. package/Grid/Grid.js.map +1 -1
  22. package/ImageEditor/ImageEditor.js +2 -0
  23. package/ImageEditor/ImageEditor.js.map +1 -1
  24. package/Input/Input.d.ts +1 -0
  25. package/Input/Input.js +13 -1
  26. package/Input/Input.js.map +1 -1
  27. package/List/DataList/DataList.js.map +1 -1
  28. package/List/DataList/DataListWithSections.d.ts +45 -0
  29. package/List/DataList/DataListWithSections.js +356 -0
  30. package/List/DataList/DataListWithSections.js.map +1 -0
  31. package/List/DataList/index.d.ts +1 -0
  32. package/List/DataList/index.js +16 -0
  33. package/List/DataList/index.js.map +1 -1
  34. package/List/List.d.ts +1 -1
  35. package/List/List.js.map +1 -1
  36. package/List/index.d.ts +1 -1
  37. package/List/index.js +14 -0
  38. package/List/index.js.map +1 -1
  39. package/Menu/Menu.d.ts +0 -2
  40. package/Menu/Menu.js +1 -4
  41. package/Menu/Menu.js.map +1 -1
  42. package/Select/Select.js +2 -1
  43. package/Select/Select.js.map +1 -1
  44. package/Tabs/Tab.js +23 -10
  45. package/Tabs/Tab.js.map +1 -1
  46. package/Tabs/Tabs.d.ts +37 -21
  47. package/Tabs/Tabs.js +115 -142
  48. package/Tabs/Tabs.js.map +1 -1
  49. package/Tooltip/Tooltip.d.ts +1 -1
  50. package/TopAppBar/TopAppBarActionItem.d.ts +1 -1
  51. package/TopAppBar/TopAppBarActionItem.js.map +1 -1
  52. package/TopAppBar/TopAppBarNavigationIcon.d.ts +1 -1
  53. package/TopAppBar/TopAppBarNavigationIcon.js.map +1 -1
  54. package/package.json +32 -44
  55. package/styles.scss +1 -1
  56. package/Chips/ChipIcon.d.ts +0 -4
  57. package/Chips/ChipIcon.js +0 -22
  58. package/Chips/ChipIcon.js.map +0 -1
  59. package/rmwc/base/LICENSE +0 -21
  60. package/rmwc/base/README.md +0 -3
  61. package/rmwc/base/code/component.d.ts +0 -18
  62. package/rmwc/base/code/component.js +0 -163
  63. package/rmwc/base/code/foundation-component.d.ts +0 -79
  64. package/rmwc/base/code/foundation-component.js +0 -354
  65. package/rmwc/base/code/index.d.ts +0 -16
  66. package/rmwc/base/code/index.js +0 -25
  67. package/rmwc/base/code/test-polyfill.d.ts +0 -3
  68. package/rmwc/base/code/test-polyfill.js +0 -33
  69. package/rmwc/base/code/utils/apply-passive.d.ts +0 -13
  70. package/rmwc/base/code/utils/apply-passive.js +0 -63
  71. package/rmwc/base/code/utils/debounce.d.ts +0 -2
  72. package/rmwc/base/code/utils/debounce.js +0 -17
  73. package/rmwc/base/code/utils/deprecation.d.ts +0 -10
  74. package/rmwc/base/code/utils/deprecation.js +0 -76
  75. package/rmwc/base/code/utils/emitter.d.ts +0 -13
  76. package/rmwc/base/code/utils/emitter.js +0 -120
  77. package/rmwc/base/code/utils/events-map.d.ts +0 -87
  78. package/rmwc/base/code/utils/events-map.js +0 -90
  79. package/rmwc/base/code/utils/index.d.ts +0 -10
  80. package/rmwc/base/code/utils/index.js +0 -19
  81. package/rmwc/base/code/utils/ponyfills.d.ts +0 -3
  82. package/rmwc/base/code/utils/ponyfills.js +0 -29
  83. package/rmwc/base/code/utils/random-id.d.ts +0 -6
  84. package/rmwc/base/code/utils/random-id.js +0 -14
  85. package/rmwc/base/code/utils/strings.d.ts +0 -3
  86. package/rmwc/base/code/utils/strings.js +0 -13
  87. package/rmwc/base/code/utils/use-knob.d.ts +0 -2
  88. package/rmwc/base/code/utils/use-knob.js +0 -64
  89. package/rmwc/base/code/utils/wrap-child.d.ts +0 -3
  90. package/rmwc/base/code/utils/wrap-child.js +0 -55
  91. package/rmwc/base/code/with-theme.d.ts +0 -15
  92. package/rmwc/base/code/with-theme.js +0 -106
  93. package/rmwc/base/package.json +0 -40
  94. package/rmwc/textfield/code/index.d.ts +0 -135
  95. package/rmwc/textfield/code/index.js +0 -571
  96. package/rmwc/textfield/next/index.d.ts +0 -135
  97. package/rmwc/textfield/next/index.js +0 -560
  98. package/rmwc/textfield/package.json +0 -45
@@ -1,135 +0,0 @@
1
- /* eslint-disable */
2
- import * as RMWC from '@rmwc/types';
3
- import * as React from 'react';
4
- import { IconProps } from '@rmwc/icon';
5
- import { SpecificEventListener } from '@material/base/types';
6
- import { MDCTextFieldFoundation, MDCTextFieldIconFoundation, MDCTextFieldCharacterCounterFoundation } from '@material/textfield';
7
- import { FoundationComponent } from '@rmwc/base';
8
- /*********************************************************************
9
- * TextField
10
- *********************************************************************/
11
- /** A TextField component for accepting text input from a user. */
12
- export interface TextFieldProps {
13
- /** Sets the value for controlled TextFields. */
14
- value?: string | number;
15
- /** Adds help text to the field */
16
- helpText?: React.ReactNode | TextFieldHelperTextProps;
17
- /** Shows the character count, must be used in conjunction with maxLength. */
18
- characterCount?: boolean;
19
- /** Makes the TextField visually invalid. This is sometimes automatically applied in cases where required or pattern is used. */
20
- invalid?: boolean;
21
- /** Makes the Textfield disabled. */
22
- disabled?: boolean;
23
- /** Makes the Textfield required. */
24
- required?: boolean;
25
- /** Outline the TextField */
26
- outlined?: boolean;
27
- /** A label for the input. */
28
- label?: React.ReactNode;
29
- /** Makes a multiline TextField. */
30
- textarea?: boolean;
31
- /** Makes the TextField fullwidth. */
32
- fullwidth?: boolean;
33
- /** Add a leading icon. */
34
- icon?: RMWC.IconPropT;
35
- /** Add a trailing icon. */
36
- trailingIcon?: RMWC.IconPropT;
37
- /** By default, props spread to the input. These props are for the component's root container. */
38
- rootProps?: Object;
39
- /** A reference to the native input or textarea. */
40
- inputRef?: React.MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null> | ((ref: HTMLInputElement | HTMLTextAreaElement | null) => void);
41
- /** The type of input field to render, search, number, etc */
42
- type?: string;
43
- }
44
- export interface DeprecatedTextfieldProps {
45
- /** DEPRECATED: Is being removed from MCW. */
46
- dense?: boolean;
47
- /** DEPRECATED: Use icon. */
48
- withLeadingIcon?: RMWC.IconPropT;
49
- /** DEPRECATED: Use trailingIcon. */
50
- withTrailingIcon?: RMWC.IconPropT;
51
- }
52
- /** A TextField component for accepting text input from a user. */
53
- export declare class TextField extends FoundationComponent<MDCTextFieldFoundation, TextFieldProps & DeprecatedTextfieldProps> {
54
- static displayName: string;
55
- generatedId: string;
56
- private root;
57
- private input;
58
- private label;
59
- private lineRipple;
60
- characterCounter?: null | TextFieldCharacterCount;
61
- leadingIcon: null | TextFieldIcon;
62
- trailingIcon: null | TextFieldIcon;
63
- outline: null | any;
64
- valueNeedsUpdate: boolean;
65
- constructor(props: any);
66
- getDefaultFoundation(): MDCTextFieldFoundation;
67
- getLabelAdapterMethods(): {
68
- shakeLabel: (shouldShake: boolean) => void;
69
- floatLabel: (shouldFloat: boolean) => void;
70
- hasLabel: () => boolean;
71
- getLabelWidth: () => number;
72
- };
73
- getLineRippleAdapterMethods(): {
74
- activateLineRipple: () => void;
75
- deactivateLineRipple: () => void;
76
- setLineRippleTransformOrigin: (normalizedX: number) => void;
77
- };
78
- getOutlineAdapterMethods(): {
79
- notchOutline: (labelWidth: number) => void;
80
- closeOutline: () => any;
81
- hasOutline: () => boolean;
82
- };
83
- getInputAdapterMethods(): {
84
- registerInputInteractionHandler: <K>(evtType: K, handler: SpecificEventListener<any>) => void;
85
- deregisterInputInteractionHandler: <K>(evtType: K, handler: SpecificEventListener<any>) => void;
86
- getNativeInput: () => (HTMLInputElement & HTMLTextAreaElement) | null;
87
- };
88
- getFoundationMap(): {
89
- characterCounter: MDCTextFieldCharacterCounterFoundation | undefined;
90
- helperText: undefined;
91
- leadingIcon: MDCTextFieldIconFoundation | undefined;
92
- trailingIcon: MDCTextFieldIconFoundation | undefined;
93
- };
94
- renderIcon(icon: RMWC.IconPropT, leadOrTrail: 'leadingIcon' | 'trailingIcon'): JSX.Element;
95
- sync(props: TextFieldProps): void;
96
- handleOnChange(evt: React.ChangeEvent<HTMLInputElement>): void;
97
- renderHelpText(renderedCharacterCounter?: React.ReactNode): JSX.Element | null;
98
- render(): JSX.Element;
99
- }
100
- /*********************************************************************
101
- * Helper Text
102
- *********************************************************************/
103
- interface TextFieldHelperCharacterCount {
104
- }
105
- declare class TextFieldCharacterCount extends FoundationComponent<MDCTextFieldCharacterCounterFoundation, TextFieldHelperCharacterCount> {
106
- static displayName: string;
107
- state: {
108
- content: string;
109
- };
110
- getDefaultFoundation(): MDCTextFieldCharacterCounterFoundation;
111
- render(): JSX.Element;
112
- }
113
- export interface TextFieldHelperTextProps {
114
- /** Make the help text always visible */
115
- persistent?: boolean;
116
- /** Make the help a validation message style */
117
- validationMsg?: boolean;
118
- /** Content for the help text */
119
- children: React.ReactNode;
120
- }
121
- /** A help text component */
122
- export declare const TextFieldHelperText: React.ComponentType<RMWC.MergeInterfacesT<TextFieldHelperTextProps, RMWC.ComponentProps>>;
123
- /*********************************************************************
124
- * Icon
125
- *********************************************************************/
126
- /**
127
- * An Icon in a TextField
128
- */
129
- export declare class TextFieldIcon extends FoundationComponent<MDCTextFieldIconFoundation, IconProps> {
130
- static displayName: string;
131
- private root;
132
- getDefaultFoundation(): MDCTextFieldIconFoundation;
133
- render(): JSX.Element;
134
- }
135
- export {};
@@ -1,560 +0,0 @@
1
- /* eslint-disable */
2
- var __extends =
3
- (this && this.__extends) ||
4
- (function () {
5
- var extendStatics = function (d, b) {
6
- extendStatics =
7
- Object.setPrototypeOf ||
8
- ({ __proto__: [] } instanceof Array &&
9
- function (d, b) {
10
- d.__proto__ = b;
11
- }) ||
12
- function (d, b) {
13
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
14
- };
15
- return extendStatics(d, b);
16
- };
17
- return function (d, b) {
18
- extendStatics(d, b);
19
- function __() {
20
- this.constructor = d;
21
- }
22
- d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
23
- };
24
- })();
25
- var __assign =
26
- (this && this.__assign) ||
27
- function () {
28
- __assign =
29
- Object.assign ||
30
- function (t) {
31
- for (var s, i = 1, n = arguments.length; i < n; i++) {
32
- s = arguments[i];
33
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
34
- }
35
- return t;
36
- };
37
- return __assign.apply(this, arguments);
38
- };
39
- var __rest =
40
- (this && this.__rest) ||
41
- function (s, e) {
42
- var t = {};
43
- for (var p in s)
44
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
45
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
46
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
47
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
48
- t[p[i]] = s[p[i]];
49
- }
50
- return t;
51
- };
52
- import * as React from "react";
53
- import {
54
- MDCTextFieldFoundation,
55
- MDCTextFieldIconFoundation,
56
- MDCTextFieldCharacterCounterFoundation
57
- } from "@material/textfield";
58
- import { componentFactory, FoundationComponent, randomId, deprecationWarning } from "@rmwc/base";
59
- import { Icon } from "@rmwc/icon";
60
- import { LineRipple } from "@rmwc/line-ripple";
61
- import { FloatingLabel } from "@rmwc/floating-label";
62
- import { NotchedOutline } from "@rmwc/notched-outline";
63
- import { withRipple } from "@rmwc/ripple";
64
- var TextFieldRoot = withRipple()(
65
- componentFactory({
66
- displayName: "TextFieldRoot",
67
- deprecate: {
68
- box: ""
69
- },
70
- classNames: function (props) {
71
- return [
72
- "mdc-text-field",
73
- "mdc-text-field--upgraded",
74
- {
75
- "mdc-text-field--textarea": props.textarea,
76
- "mdc-text-field--fullwidth": props.fullwidth,
77
- "mdc-text-field--outlined": props.outlined,
78
- "mdc-text-field--dense": props.dense,
79
- "mdc-text-field--invalid": props.invalid,
80
- "mdc-text-field--disabled": props.disabled,
81
- "mdc-text-field--with-leading-icon": !!props.icon,
82
- "mdc-text-field--with-trailing-icon": !!props.trailingIcon,
83
- "mdc-text-field--no-label": !props.label
84
- }
85
- ];
86
- },
87
- consumeProps: [
88
- "textarea",
89
- "fullwidth",
90
- "outlined",
91
- "dense",
92
- "invalid",
93
- "disabled",
94
- "icon",
95
- "trailingIcon",
96
- "label"
97
- ]
98
- })
99
- );
100
- var TextFieldInput = componentFactory({
101
- displayName: "TextFieldInput",
102
- defaultProps: {
103
- type: "text"
104
- },
105
- tag: "input",
106
- classNames: ["mdc-text-field__input"]
107
- });
108
- var TextFieldTextarea = componentFactory({
109
- displayName: "TextFieldTextarea",
110
- tag: "textarea",
111
- classNames: ["mdc-text-field__input"]
112
- });
113
- /** A TextField component for accepting text input from a user. */
114
- var TextField = /** @class */ (function (_super) {
115
- __extends(TextField, _super);
116
- function TextField(props) {
117
- var _this = _super.call(this, props) || this;
118
- _this.generatedId = randomId("textfield");
119
- _this.root = _this.createElement("root");
120
- _this.input = _this.createElement("input");
121
- _this.label = _this.createElement("label");
122
- _this.lineRipple = _this.createElement("lineRipple");
123
- _this.characterCounter = null;
124
- _this.leadingIcon = null;
125
- _this.trailingIcon = null;
126
- _this.valueNeedsUpdate = false;
127
- _this.handleOnChange = _this.handleOnChange.bind(_this);
128
- return _this;
129
- }
130
- TextField.prototype.getDefaultFoundation = function () {
131
- var _this = this;
132
- return new MDCTextFieldFoundation(
133
- __assign(
134
- {
135
- addClass: function (className) {
136
- return _this.root.addClass(className);
137
- },
138
- removeClass: function (className) {
139
- return _this.root.removeClass(className);
140
- },
141
- hasClass: function (className) {
142
- return _this.root.hasClass(className);
143
- },
144
- registerTextFieldInteractionHandler: function (evtType, handler) {
145
- return _this.root.addEventListener(evtType, handler);
146
- },
147
- deregisterTextFieldInteractionHandler: function (evtType, handler) {
148
- return _this.root.removeEventListener(evtType, handler);
149
- },
150
- registerValidationAttributeChangeHandler: function (handler) {
151
- var getAttributesList = function (mutationsList) {
152
- return mutationsList.map(function (mutation) {
153
- return mutation.attributeName;
154
- });
155
- };
156
- if (_this.input.ref) {
157
- var observer = new MutationObserver(function (mutationsList) {
158
- return handler(getAttributesList(mutationsList));
159
- });
160
- var targetNode = _this.input.ref;
161
- var config = { attributes: true };
162
- targetNode && observer.observe(targetNode, config);
163
- return observer;
164
- }
165
- return {};
166
- },
167
- deregisterValidationAttributeChangeHandler: function (observer) {
168
- observer && observer.disconnect();
169
- },
170
- isFocused: function () {
171
- return document.activeElement === _this.input.ref;
172
- }
173
- },
174
- this.getInputAdapterMethods(),
175
- this.getLabelAdapterMethods(),
176
- this.getLineRippleAdapterMethods(),
177
- this.getOutlineAdapterMethods()
178
- ),
179
- this.getFoundationMap()
180
- );
181
- };
182
- TextField.prototype.getLabelAdapterMethods = function () {
183
- var _this = this;
184
- return {
185
- shakeLabel: function (shouldShake) {
186
- return _this.label.setProp("shake", shouldShake);
187
- },
188
- floatLabel: function (shouldFloat) {
189
- return _this.label.setProp("float", shouldFloat);
190
- },
191
- hasLabel: function () {
192
- return !!_this.props.label;
193
- },
194
- getLabelWidth: function () {
195
- return _this.label.ref ? _this.label.ref.getWidth() : 0;
196
- }
197
- };
198
- };
199
- TextField.prototype.getLineRippleAdapterMethods = function () {
200
- var _this = this;
201
- return {
202
- activateLineRipple: function () {
203
- if (_this.lineRipple) {
204
- _this.lineRipple.setProp("active", true);
205
- }
206
- },
207
- deactivateLineRipple: function () {
208
- if (_this.lineRipple) {
209
- _this.lineRipple.setProp("active", false);
210
- }
211
- },
212
- setLineRippleTransformOrigin: function (normalizedX) {
213
- if (_this.lineRipple) {
214
- _this.lineRipple.setProp("center", normalizedX);
215
- }
216
- }
217
- };
218
- };
219
- TextField.prototype.getOutlineAdapterMethods = function () {
220
- var _this = this;
221
- return {
222
- notchOutline: function (labelWidth) {
223
- !!_this.outline && _this.outline.notch(labelWidth);
224
- },
225
- closeOutline: function () {
226
- return _this.outline && _this.outline.closeNotch();
227
- },
228
- hasOutline: function () {
229
- return !!_this.outline;
230
- }
231
- };
232
- };
233
- TextField.prototype.getInputAdapterMethods = function () {
234
- var _this = this;
235
- return {
236
- registerInputInteractionHandler: function (evtType, handler) {
237
- return _this.input.addEventListener(evtType, handler);
238
- },
239
- deregisterInputInteractionHandler: function (evtType, handler) {
240
- return _this.input.removeEventListener(evtType, handler);
241
- },
242
- getNativeInput: function () {
243
- return _this.input.ref;
244
- }
245
- };
246
- };
247
- TextField.prototype.getFoundationMap = function () {
248
- return {
249
- characterCounter: this.characterCounter ? this.characterCounter.foundation : undefined,
250
- helperText: undefined,
251
- leadingIcon: this.leadingIcon ? this.leadingIcon.foundation : undefined,
252
- trailingIcon: this.trailingIcon ? this.trailingIcon.foundation : undefined
253
- };
254
- };
255
- // handle leading and trailing icons
256
- TextField.prototype.renderIcon = function (icon, leadOrTrail) {
257
- var _this = this;
258
- return React.createElement(TextFieldIcon, {
259
- ref: function (ref) {
260
- if (leadOrTrail === "leadingIcon") {
261
- _this.leadingIcon = ref;
262
- } else {
263
- _this.trailingIcon = ref;
264
- }
265
- },
266
- tabIndex: leadOrTrail === "trailingIcon" ? 0 : undefined,
267
- icon: icon
268
- });
269
- };
270
- TextField.prototype.sync = function (props) {
271
- // Bug #362
272
- // see comments below in render function
273
- if (this.valueNeedsUpdate) {
274
- this.foundation.setValue(String(props.value));
275
- this.valueNeedsUpdate = false;
276
- }
277
- };
278
- TextField.prototype.handleOnChange = function (evt) {
279
- // this.props.onChange && this.props.onChange(evt);
280
- // this.setState({});
281
- };
282
- TextField.prototype.renderHelpText = function (renderedCharacterCounter) {
283
- var _a = this.props,
284
- helpText = _a.helpText,
285
- characterCount = _a.characterCount,
286
- textarea = _a.textarea;
287
- var shouldRender = !!helpText || (characterCount && !textarea);
288
- if (!shouldRender) {
289
- return null;
290
- }
291
- var shouldSpread = typeof helpText === "object" && !React.isValidElement(helpText);
292
- return React.createElement(
293
- "div",
294
- { className: "mdc-text-field-helper-line" },
295
- helpText && shouldSpread
296
- ? React.createElement(TextFieldHelperText, __assign({}, helpText))
297
- : React.createElement(TextFieldHelperText, null, helpText),
298
- !textarea && renderedCharacterCounter
299
- );
300
- };
301
- TextField.prototype.render = function () {
302
- var _this = this;
303
- var _a = this.props,
304
- label = _a.label,
305
- className = _a.className,
306
- style = _a.style,
307
- outlined = _a.outlined,
308
- fullwidth = _a.fullwidth,
309
- dense = _a.dense,
310
- invalid = _a.invalid,
311
- disabled = _a.disabled,
312
- helpText = _a.helpText,
313
- children = _a.children,
314
- textarea = _a.textarea,
315
- inputRef = _a.inputRef,
316
- characterCount = _a.characterCount,
317
- _icon = _a.icon,
318
- _trailingIcon = _a.trailingIcon,
319
- _withLeadingIcon = _a.withLeadingIcon,
320
- _withTrailingIcon = _a.withTrailingIcon,
321
- _b = _a.rootProps,
322
- rootProps = _b === void 0 ? {} : _b,
323
- rest = __rest(_a, [
324
- "label",
325
- "className",
326
- "style",
327
- "outlined",
328
- "fullwidth",
329
- "dense",
330
- "invalid",
331
- "disabled",
332
- "helpText",
333
- "children",
334
- "textarea",
335
- "inputRef",
336
- "characterCount",
337
- "icon",
338
- "trailingIcon",
339
- "withLeadingIcon",
340
- "withTrailingIcon",
341
- "rootProps"
342
- ]);
343
- var _c = this.props,
344
- icon = _c.icon,
345
- trailingIcon = _c.trailingIcon,
346
- withLeadingIcon = _c.withLeadingIcon,
347
- withTrailingIcon = _c.withTrailingIcon;
348
- if (dense !== undefined) {
349
- deprecationWarning(
350
- "Textfield prop 'dense' is being removed in a future release by material-components-web."
351
- );
352
- }
353
- if (withLeadingIcon !== undefined) {
354
- deprecationWarning("Textfield prop 'withLeadingIcon' is now 'icon'.");
355
- icon = withLeadingIcon;
356
- }
357
- if (withTrailingIcon !== undefined) {
358
- deprecationWarning("Textfield prop 'withTrailingIcon' is now 'trailingIcon'.");
359
- trailingIcon = withTrailingIcon;
360
- }
361
- // Fixes bug #362
362
- // MDC breaks Reacts unidirectional data flow...
363
- // we cant set the value on render, but we need to
364
- // to create the side effects for the UI when we dynamically update the field
365
- // Flag that it needs to be set so that we can call the foundation
366
- // on componentDidUpdate
367
- if (
368
- this.props.value !== undefined &&
369
- this.foundation &&
370
- this.props.value !== this.foundation.getValue()
371
- ) {
372
- this.valueNeedsUpdate = true;
373
- }
374
- var tagProps = __assign({}, this.input.props(rest), {
375
- disabled: disabled,
376
- ref: function (ref) {
377
- _this.input.setRef(ref);
378
- if (typeof inputRef === "function") {
379
- inputRef && inputRef(ref);
380
- } else if (typeof inputRef === "object") {
381
- inputRef.current = ref;
382
- }
383
- },
384
- id: rest.id || this.generatedId
385
- });
386
- var renderedTag = textarea
387
- ? React.createElement(TextFieldTextarea, __assign({}, tagProps))
388
- : React.createElement(TextFieldInput, __assign({}, tagProps));
389
- var renderedLabel = label
390
- ? React.createElement(
391
- FloatingLabel,
392
- __assign({}, this.label.props({}), {
393
- ref: this.label.setRef,
394
- htmlFor: tagProps.id
395
- }),
396
- label
397
- )
398
- : null;
399
- var renderedCharacterCounter = characterCount
400
- ? React.createElement(
401
- TextFieldCharacterCount,
402
- {
403
- ref: function (el) {
404
- _this.characterCounter = el;
405
- }
406
- },
407
- "F"
408
- )
409
- : null;
410
- return React.createElement(
411
- React.Fragment,
412
- null,
413
- React.createElement(
414
- TextFieldRoot,
415
- __assign(
416
- {},
417
- this.root.props(
418
- __assign({}, rootProps, { className: className, style: style })
419
- ),
420
- {
421
- label: label,
422
- invalid: invalid,
423
- icon: !!icon,
424
- trailingIcon: !!trailingIcon,
425
- textarea: textarea,
426
- dense: dense,
427
- disabled: disabled,
428
- outlined: outlined,
429
- fullwidth: fullwidth,
430
- ref: this.root.setRef
431
- }
432
- ),
433
- !!icon && this.renderIcon(icon, "leadingIcon"),
434
- children,
435
- !!textarea && renderedCharacterCounter,
436
- renderedTag,
437
- !!outlined
438
- ? React.createElement(
439
- React.Fragment,
440
- null,
441
- React.createElement(
442
- NotchedOutline,
443
- {
444
- ref: function (ref) {
445
- return (_this.outline = ref && ref.foundation);
446
- }
447
- },
448
- renderedLabel
449
- ),
450
- !!trailingIcon && this.renderIcon(trailingIcon, "trailingIcon")
451
- )
452
- : React.createElement(
453
- React.Fragment,
454
- null,
455
- renderedLabel,
456
- !!trailingIcon && this.renderIcon(trailingIcon, "trailingIcon"),
457
- React.createElement(LineRipple, __assign({}, this.lineRipple.props({})))
458
- )
459
- ),
460
- this.renderHelpText(renderedCharacterCounter)
461
- );
462
- };
463
- TextField.displayName = "TextField";
464
- return TextField;
465
- })(FoundationComponent);
466
- export { TextField };
467
- var TextFieldCharacterCount = /** @class */ (function (_super) {
468
- __extends(TextFieldCharacterCount, _super);
469
- function TextFieldCharacterCount() {
470
- var _this = (_super !== null && _super.apply(this, arguments)) || this;
471
- _this.state = {
472
- content: ""
473
- };
474
- return _this;
475
- }
476
- TextFieldCharacterCount.prototype.getDefaultFoundation = function () {
477
- var _this = this;
478
- return new MDCTextFieldCharacterCounterFoundation({
479
- setContent: function (content) {
480
- _this.setState({ content: content });
481
- }
482
- });
483
- };
484
- TextFieldCharacterCount.prototype.render = function () {
485
- return React.createElement(
486
- "div",
487
- { className: "mdc-text-field-character-counter" },
488
- this.state.content
489
- );
490
- };
491
- TextFieldCharacterCount.displayName = "TextFieldCharacterCount";
492
- return TextFieldCharacterCount;
493
- })(FoundationComponent);
494
- /** A help text component */
495
- export var TextFieldHelperText = componentFactory({
496
- displayName: "TextFieldHelperText",
497
- classNames: function (props) {
498
- return [
499
- "mdc-text-field-helper-text",
500
- {
501
- "mdc-text-field-helper-text--persistent": props.persistent,
502
- "mdc-text-field-helper-text--validation-msg": props.validationMsg
503
- }
504
- ];
505
- },
506
- consumeProps: ["persistent", "validationMsg"]
507
- });
508
- /*********************************************************************
509
- * Icon
510
- *********************************************************************/
511
- /**
512
- * An Icon in a TextField
513
- */
514
- var TextFieldIcon = /** @class */ (function (_super) {
515
- __extends(TextFieldIcon, _super);
516
- function TextFieldIcon() {
517
- var _this = (_super !== null && _super.apply(this, arguments)) || this;
518
- _this.root = _this.createElement("root");
519
- return _this;
520
- }
521
- TextFieldIcon.prototype.getDefaultFoundation = function () {
522
- var _this = this;
523
- return new MDCTextFieldIconFoundation({
524
- getAttr: function (attr) {
525
- return _this.root.getProp(attr);
526
- },
527
- setAttr: function (attr, value) {
528
- return _this.root.setProp(attr, value);
529
- },
530
- removeAttr: function (attr) {
531
- return _this.root.removeProp(attr);
532
- },
533
- setContent: function (content) {
534
- // @ts-ignore
535
- _this.root.setProp("icon", content);
536
- },
537
- registerInteractionHandler: function (evtType, handler) {
538
- return _this.root.addEventListener(evtType, handler);
539
- },
540
- deregisterInteractionHandler: function (evtType, handler) {
541
- return _this.root.removeEventListener(evtType, handler);
542
- },
543
- notifyIconAction: function () {
544
- return _this.emit("onClick", {}, true);
545
- }
546
- });
547
- };
548
- TextFieldIcon.prototype.render = function () {
549
- return React.createElement(
550
- Icon,
551
- __assign(
552
- {},
553
- this.root.props(__assign({}, this.props, { className: "mdc-text-field__icon" }))
554
- )
555
- );
556
- };
557
- TextFieldIcon.displayName = "TextFieldIcon";
558
- return TextFieldIcon;
559
- })(FoundationComponent);
560
- export { TextFieldIcon };