superdesk-ui-framework 3.0.1-beta.3 → 3.0.1-beta.4
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/app/styles/_sd-tag-input.scss +201 -296
- package/app/styles/components/_list-item.scss +13 -1
- package/app/styles/components/_sd-photo-preview.scss +1 -1
- package/app/styles/design-tokens/_new-colors.scss +1 -1
- package/app/styles/form-elements/_forms-general.scss +22 -7
- package/app/styles/form-elements/_inputs.scss +131 -54
- package/app-typescript/components/Badge.tsx +3 -2
- package/app-typescript/components/DatePicker.tsx +40 -52
- package/app-typescript/components/DurationInput.tsx +306 -0
- package/app-typescript/components/Form/InputBase.tsx +85 -0
- package/app-typescript/components/Form/InputNew.tsx +105 -0
- package/app-typescript/components/Form/InputWrapper.tsx +79 -0
- package/app-typescript/components/Form/index.tsx +3 -0
- package/app-typescript/components/Input.tsx +28 -45
- package/app-typescript/components/Label.tsx +49 -10
- package/app-typescript/components/Layouts/Layout.tsx +1 -1
- package/app-typescript/components/Lists/ContentList.tsx +4 -4
- package/app-typescript/components/MultiSelect.tsx +37 -50
- package/app-typescript/components/Navigation/BottomNav.tsx +3 -2
- package/app-typescript/components/Select.tsx +23 -41
- package/app-typescript/components/SelectWithTemplate.tsx +32 -7
- package/app-typescript/components/TimePicker.tsx +48 -16
- package/app-typescript/components/TreeSelect.tsx +423 -195
- package/app-typescript/index.ts +3 -1
- package/dist/examples.bundle.js +16398 -15334
- package/dist/playgrounds/react-playgrounds/CoreLayout.tsx +64 -54
- package/dist/playgrounds/react-playgrounds/RundownEditor.tsx +24 -16
- package/dist/playgrounds/react-playgrounds/TestGround.tsx +76 -1
- package/dist/playgrounds/react-playgrounds/components/Layout.tsx +1 -1
- package/dist/react/Badges.tsx +18 -0
- package/dist/react/ContentList.tsx +15 -9
- package/dist/react/DatePicker.tsx +21 -1
- package/dist/react/DurationInput.tsx +104 -0
- package/dist/react/Index.tsx +5 -0
- package/dist/react/Inputs.tsx +153 -2
- package/dist/react/Labels.tsx +51 -1
- package/dist/react/MultiSelect.tsx +4 -1
- package/dist/react/SelectWithTemplate.tsx +6 -1
- package/dist/react/TableList.tsx +22 -44
- package/dist/react/TimePicker.tsx +16 -8
- package/dist/react/TreeSelect.tsx +301 -48
- package/dist/react/tree-select/TreeSelect.tsx +273 -0
- package/dist/react/tree-select/example-1.tsx +71 -0
- package/dist/react/tree-select/example-2.tsx +59 -0
- package/dist/superdesk-ui.bundle.css +411 -370
- package/dist/superdesk-ui.bundle.js +15554 -14493
- package/dist/vendor.bundle.js +27 -27
- package/examples/pages/playgrounds/react-playgrounds/CoreLayout.tsx +64 -54
- package/examples/pages/playgrounds/react-playgrounds/RundownEditor.tsx +24 -16
- package/examples/pages/playgrounds/react-playgrounds/TestGround.tsx +76 -1
- package/examples/pages/playgrounds/react-playgrounds/components/Layout.tsx +1 -1
- package/examples/pages/react/Badges.tsx +18 -0
- package/examples/pages/react/ContentList.tsx +15 -9
- package/examples/pages/react/DatePicker.tsx +21 -1
- package/examples/pages/react/DurationInput.tsx +104 -0
- package/examples/pages/react/Index.tsx +5 -0
- package/examples/pages/react/Inputs.tsx +153 -2
- package/examples/pages/react/Labels.tsx +51 -1
- package/examples/pages/react/MultiSelect.tsx +4 -1
- package/examples/pages/react/SelectWithTemplate.tsx +6 -1
- package/examples/pages/react/TableList.tsx +22 -44
- package/examples/pages/react/TimePicker.tsx +16 -8
- package/examples/pages/react/TreeSelect.tsx +301 -48
- package/examples/pages/react/tree-select/TreeSelect.tsx +273 -0
- package/examples/pages/react/tree-select/example-1.tsx +71 -0
- package/examples/pages/react/tree-select/example-2.tsx +59 -0
- package/package.json +2 -1
- package/react/components/Badge.d.ts +1 -0
- package/react/components/Badge.js +2 -2
- package/react/components/DatePicker.d.ts +1 -0
- package/react/components/DatePicker.js +6 -22
- package/react/components/DurationInput.d.ts +38 -0
- package/react/components/DurationInput.js +271 -0
- package/react/components/Form/InputBase.d.ts +42 -0
- package/react/components/Form/InputBase.js +72 -0
- package/react/components/Form/InputNew.d.ts +45 -0
- package/react/components/Form/InputNew.js +73 -0
- package/react/components/Form/InputWrapper.d.ts +28 -0
- package/react/components/Form/InputWrapper.js +91 -0
- package/react/components/Form/index.d.ts +3 -0
- package/react/components/Form/index.js +7 -1
- package/react/components/Input.js +5 -34
- package/react/components/Label.d.ts +1 -0
- package/react/components/Label.js +18 -2
- package/react/components/Layouts/Layout.js +1 -1
- package/react/components/Lists/ContentList.d.ts +45 -0
- package/react/components/Lists/ContentList.js +85 -0
- package/react/components/Navigation/BottomNav.d.ts +1 -0
- package/react/components/Navigation/BottomNav.js +2 -2
- package/react/components/Select.d.ts +1 -1
- package/react/components/Select.js +4 -26
- package/react/components/SelectWithTemplate.d.ts +11 -1
- package/react/components/SelectWithTemplate.js +19 -10
- package/react/components/TimePicker.d.ts +15 -2
- package/react/components/TimePicker.js +15 -4
- package/react/components/TreeSelect.d.ts +75 -0
- package/react/components/TreeSelect.js +448 -0
- package/react/index.d.ts +3 -0
- package/react/index.js +8 -3
@@ -0,0 +1,271 @@
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
18
|
+
if (k2 === undefined) k2 = k;
|
19
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
20
|
+
}) : (function(o, m, k, k2) {
|
21
|
+
if (k2 === undefined) k2 = k;
|
22
|
+
o[k2] = m[k];
|
23
|
+
}));
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
26
|
+
}) : function(o, v) {
|
27
|
+
o["default"] = v;
|
28
|
+
});
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
30
|
+
if (mod && mod.__esModule) return mod;
|
31
|
+
var result = {};
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
33
|
+
__setModuleDefault(result, mod);
|
34
|
+
return result;
|
35
|
+
};
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
38
|
+
};
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
40
|
+
exports.DurationInput = void 0;
|
41
|
+
var React = __importStar(require("react"));
|
42
|
+
var classnames_1 = __importDefault(require("classnames"));
|
43
|
+
var moment_1 = __importDefault(require("moment"));
|
44
|
+
var react_id_generator_1 = __importDefault(require("react-id-generator"));
|
45
|
+
var DurationInput = /** @class */ (function (_super) {
|
46
|
+
__extends(DurationInput, _super);
|
47
|
+
function DurationInput(props) {
|
48
|
+
var _a;
|
49
|
+
var _this = _super.call(this, props) || this;
|
50
|
+
_this.state = {
|
51
|
+
hours: _this.props.hours ? _this.zerPad(_this.props.hours) : _this.zerPad(0),
|
52
|
+
minutes: _this.props.minutes ? _this.zerPad(_this.props.minutes) : _this.zerPad(0),
|
53
|
+
seconds: _this.props.seconds ? _this.zerPad(_this.props.seconds) : _this.zerPad(0),
|
54
|
+
invalid: (_a = _this.props.invalid) !== null && _a !== void 0 ? _a : false,
|
55
|
+
};
|
56
|
+
_this.hourRef = React.createRef();
|
57
|
+
_this.minuteRef = React.createRef();
|
58
|
+
_this.secondRef = React.createRef();
|
59
|
+
_this.handleKeyDown = _this.handleKeyDown.bind(_this);
|
60
|
+
_this.zerPad = _this.zerPad.bind(_this);
|
61
|
+
_this.handleChange = _this.handleChange.bind(_this);
|
62
|
+
_this.handleFocusOnKeyUp = _this.handleFocusOnKeyUp.bind(_this);
|
63
|
+
_this.handleKeyValue = _this.handleKeyValue.bind(_this);
|
64
|
+
return _this;
|
65
|
+
}
|
66
|
+
DurationInput.prototype.componentDidUpdate = function (_, prevState) {
|
67
|
+
if (this.props.onChange) {
|
68
|
+
this.props.onChange(moment_1.default.duration("".concat(this.state.hours, ":").concat(this.state.minutes, ":").concat(this.state.seconds))
|
69
|
+
.asSeconds());
|
70
|
+
}
|
71
|
+
if (!this.hourRef.current || !this.minuteRef.current || !this.secondRef.current) {
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
if (this.state.hours !== prevState.hours) {
|
75
|
+
if (Number(this.hourRef.current.value) > 99) {
|
76
|
+
this.setState({
|
77
|
+
hours: this.zerPad(99),
|
78
|
+
});
|
79
|
+
}
|
80
|
+
}
|
81
|
+
if (this.state.minutes !== prevState.minutes) {
|
82
|
+
if (Number(this.minuteRef.current.value) > 59) {
|
83
|
+
this.setState({
|
84
|
+
hours: this.zerPad(Number(this.state.hours) + 1),
|
85
|
+
minutes: this.zerPad(0),
|
86
|
+
});
|
87
|
+
}
|
88
|
+
if (Number(this.minuteRef.current.value) < 0) {
|
89
|
+
this.setState({
|
90
|
+
hours: this.zerPad(Number(this.state.hours)) > 0
|
91
|
+
? this.zerPad(Number(this.state.hours) - 1)
|
92
|
+
: this.zerPad(Number(this.state.hours)),
|
93
|
+
minutes: 59,
|
94
|
+
});
|
95
|
+
}
|
96
|
+
}
|
97
|
+
if (this.state.seconds !== prevState.seconds) {
|
98
|
+
if (Number(this.secondRef.current.value) > 59) {
|
99
|
+
this.setState({
|
100
|
+
minutes: this.zerPad(Number(this.state.minutes) + 1),
|
101
|
+
seconds: this.zerPad(0),
|
102
|
+
});
|
103
|
+
}
|
104
|
+
if (Number(this.secondRef.current.value) < 0) {
|
105
|
+
this.setState({
|
106
|
+
minutes: this.zerPad(Number(this.state.minutes) - 1),
|
107
|
+
seconds: 59,
|
108
|
+
});
|
109
|
+
}
|
110
|
+
}
|
111
|
+
};
|
112
|
+
DurationInput.prototype.handleKeyDown = function (event) {
|
113
|
+
if (!(event.target instanceof HTMLInputElement)) {
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
if (event.target.id === 'hours') {
|
117
|
+
if (event.key === 'ArrowRight') {
|
118
|
+
if (event.target.selectionEnd === event.target.value.length) {
|
119
|
+
this.handleFocus(this.minuteRef.current, event.target.id);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
if (event.key === 'ArrowLeft') {
|
123
|
+
if (event.target.selectionStart === 0) {
|
124
|
+
this.handleFocus(this.secondRef.current, event.target.id);
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
if (event.target.id === 'minutes') {
|
129
|
+
if (event.key === 'ArrowRight') {
|
130
|
+
if (event.target.selectionEnd === event.target.value.length) {
|
131
|
+
this.handleFocus(this.secondRef.current, event.target.id);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
if (event.key === 'ArrowLeft') {
|
135
|
+
if (event.target.selectionStart === 0) {
|
136
|
+
this.handleFocus(this.hourRef.current, event.target.id);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
}
|
140
|
+
if (event.target.id === 'seconds') {
|
141
|
+
if (event.key === 'ArrowRight') {
|
142
|
+
if (event.target.selectionEnd === event.target.value.length) {
|
143
|
+
this.handleFocus(this.hourRef.current, event.target.id);
|
144
|
+
}
|
145
|
+
}
|
146
|
+
if (event.key === 'ArrowLeft') {
|
147
|
+
if (event.target.selectionStart === 0) {
|
148
|
+
this.handleFocus(this.minuteRef.current, event.target.id);
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
153
|
+
this.handleKeyValue(event, event.target.id);
|
154
|
+
}
|
155
|
+
};
|
156
|
+
DurationInput.prototype.handleKeyValue = function (event, state) {
|
157
|
+
if (!(event.target instanceof HTMLInputElement)) {
|
158
|
+
return;
|
159
|
+
}
|
160
|
+
if (!this.state[state]) {
|
161
|
+
return;
|
162
|
+
}
|
163
|
+
event.preventDefault();
|
164
|
+
event.stopPropagation();
|
165
|
+
var stateClone = {};
|
166
|
+
if (event.key === 'ArrowUp') {
|
167
|
+
if (event.target.id === 'hours') {
|
168
|
+
stateClone[state] = this.state[state] < 99
|
169
|
+
? this.zerPad(Number(this.state[state]) + 1)
|
170
|
+
: this.zerPad(99);
|
171
|
+
}
|
172
|
+
else {
|
173
|
+
stateClone[state] = this.zerPad(Number(this.state[state]) + 1);
|
174
|
+
}
|
175
|
+
}
|
176
|
+
else if (event.key === 'ArrowDown') {
|
177
|
+
if (event.target.id === 'hours') {
|
178
|
+
stateClone[state] = this.state[state] > 0 ? this.zerPad(Number(this.state[state]) - 1) : this.zerPad(0);
|
179
|
+
}
|
180
|
+
else {
|
181
|
+
stateClone[state] = this.zerPad(Number(this.state[state]) - 1);
|
182
|
+
}
|
183
|
+
}
|
184
|
+
this.setState(stateClone);
|
185
|
+
};
|
186
|
+
DurationInput.prototype.zerPad = function (value) {
|
187
|
+
if (value.toString().length === 1 || value === 0) {
|
188
|
+
return "0".concat(value);
|
189
|
+
}
|
190
|
+
else if (!value) {
|
191
|
+
return '00';
|
192
|
+
}
|
193
|
+
else {
|
194
|
+
return value;
|
195
|
+
}
|
196
|
+
};
|
197
|
+
DurationInput.prototype.handleChange = function (event, state) {
|
198
|
+
var stateClone = {};
|
199
|
+
if (event.target.value.length >= 2) {
|
200
|
+
stateClone[state] = event.target.value.slice(0, 2);
|
201
|
+
}
|
202
|
+
else {
|
203
|
+
stateClone[state] = event.target.value;
|
204
|
+
}
|
205
|
+
this.setState(stateClone);
|
206
|
+
};
|
207
|
+
DurationInput.prototype.handleFocus = function (ref, state) {
|
208
|
+
ref === null || ref === void 0 ? void 0 : ref.focus();
|
209
|
+
setTimeout(function () {
|
210
|
+
ref === null || ref === void 0 ? void 0 : ref.setSelectionRange(0, 2);
|
211
|
+
});
|
212
|
+
var stateClone = {};
|
213
|
+
stateClone[state] = this.zerPad(this.state[state]);
|
214
|
+
this.setState(stateClone);
|
215
|
+
};
|
216
|
+
DurationInput.prototype.handleFocusOnKeyUp = function (event, ref) {
|
217
|
+
if (event.key !== 'ArrowRight' && event.key !== 'ArrowLeft' && event.key !== 'ArrowUp' && event.key !== 'ArrowDown' && event.key !== 'Backspace') {
|
218
|
+
var target = event.target;
|
219
|
+
if (target.value.length >= 2) {
|
220
|
+
ref === null || ref === void 0 ? void 0 : ref.focus();
|
221
|
+
setTimeout(function () {
|
222
|
+
ref === null || ref === void 0 ? void 0 : ref.setSelectionRange(0, 2);
|
223
|
+
});
|
224
|
+
}
|
225
|
+
}
|
226
|
+
};
|
227
|
+
DurationInput.prototype.render = function () {
|
228
|
+
var _this = this;
|
229
|
+
var InputClasses = (0, classnames_1.default)('sd-input__duration-input');
|
230
|
+
var classes = (0, classnames_1.default)('sd-input', {
|
231
|
+
'sd-input--inline-label': this.props.inlineLabel,
|
232
|
+
'sd-input--required': this.props.required,
|
233
|
+
'sd-input--disabled': this.props.disabled,
|
234
|
+
'sd-input--full-width': this.props.fullWidth,
|
235
|
+
'sd-input--invalid': this.props.invalid || this.state.invalid,
|
236
|
+
});
|
237
|
+
var labelClasses = (0, classnames_1.default)('sd-input__label', {
|
238
|
+
'a11y-only': this.props.labelHidden,
|
239
|
+
});
|
240
|
+
var htmlId = (0, react_id_generator_1.default)();
|
241
|
+
return (React.createElement("div", { className: classes },
|
242
|
+
React.createElement("label", { className: labelClasses, htmlFor: htmlId, id: htmlId + 'label', tabIndex: this.props.tabindex === undefined ? undefined : -1 }, this.props.label),
|
243
|
+
React.createElement("div", { className: InputClasses },
|
244
|
+
React.createElement("input", { className: 'duration-input', type: 'text', id: 'hours', max: 99, min: 0, ref: this.hourRef, value: this.state.hours, disabled: this.props.disabled, onKeyDown: function (event) { return _this.handleKeyDown(event); }, onKeyUp: function (event) { return _this.handleFocusOnKeyUp(event, _this.minuteRef.current); }, onChange: function (event) { _this.handleChange(event, 'hours'); }, onBlur: function (event) { return _this.setState({ hours: _this.zerPad(event.target.value) }); }, onKeyPress: function (event) {
|
245
|
+
if (!/[0-9]/.test(event.key)) {
|
246
|
+
event.preventDefault();
|
247
|
+
}
|
248
|
+
} }),
|
249
|
+
React.createElement("span", { className: 'sd-input__suffix' }, "h"),
|
250
|
+
React.createElement("input", { className: 'duration-input', type: 'text', id: 'minutes', ref: this.minuteRef, value: this.state.minutes, disabled: this.props.disabled, onKeyDown: function (event) { return _this.handleKeyDown(event); }, onKeyUp: function (event) { return _this.handleFocusOnKeyUp(event, _this.secondRef.current); }, onChange: function (event) { _this.handleChange(event, 'minutes'); }, onBlur: function (event) { return _this.setState({ minutes: _this.zerPad(event.target.value) }); }, onKeyPress: function (event) {
|
251
|
+
if (!/[0-9]/.test(event.key)) {
|
252
|
+
event.preventDefault();
|
253
|
+
}
|
254
|
+
} }),
|
255
|
+
React.createElement("span", { className: 'sd-input__suffix' }, "m"),
|
256
|
+
React.createElement("input", { className: 'duration-input', type: 'text', id: 'seconds', ref: this.secondRef, value: this.state.seconds, disabled: this.props.disabled, onKeyDown: function (event) { return _this.handleKeyDown(event); }, onKeyUp: function (event) { return _this.handleFocusOnKeyUp(event, _this.hourRef.current); }, onChange: function (event) { _this.handleChange(event, 'seconds'); }, onBlur: function (event) { return _this.setState({ seconds: _this.zerPad(event.target.value) }); }, onKeyPress: function (event) {
|
257
|
+
if (!/[0-9]/.test(event.key)) {
|
258
|
+
event.preventDefault();
|
259
|
+
}
|
260
|
+
} }),
|
261
|
+
React.createElement("span", { className: 'sd-input__suffix' }, "s")),
|
262
|
+
React.createElement("div", { className: 'sd-input__message-box' },
|
263
|
+
this.props.info && !this.props.invalid && !this.state.invalid ?
|
264
|
+
React.createElement("div", { className: 'sd-input__hint' }, this.props.info) : null,
|
265
|
+
this.props.invalid || this.state.invalid ?
|
266
|
+
React.createElement("div", { className: 'sd-input__message' }, this.props.error)
|
267
|
+
: null)));
|
268
|
+
};
|
269
|
+
return DurationInput;
|
270
|
+
}(React.PureComponent));
|
271
|
+
exports.DurationInput = DurationInput;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
interface IPropsBase {
|
3
|
+
error?: string;
|
4
|
+
required?: boolean;
|
5
|
+
disabled?: boolean;
|
6
|
+
invalid?: boolean;
|
7
|
+
tabIndex?: number;
|
8
|
+
fullWidth?: boolean;
|
9
|
+
boxedStyle?: boolean;
|
10
|
+
boxedLable?: boolean;
|
11
|
+
placeholder?: string;
|
12
|
+
htmlId?: string;
|
13
|
+
id?: string;
|
14
|
+
size?: 'medium' | 'large' | 'x-large';
|
15
|
+
}
|
16
|
+
interface IPropsText extends IPropsBase {
|
17
|
+
type: 'text';
|
18
|
+
value: string;
|
19
|
+
onChange(newValue: string): void;
|
20
|
+
}
|
21
|
+
interface IPropsPassword extends IPropsBase {
|
22
|
+
type: 'password';
|
23
|
+
value: string;
|
24
|
+
onChange(newValue: string): void;
|
25
|
+
}
|
26
|
+
interface IPropsNumber extends IPropsBase {
|
27
|
+
type: 'number';
|
28
|
+
value: number;
|
29
|
+
onChange(newValue: number): void;
|
30
|
+
}
|
31
|
+
declare type IProps = IPropsText | IPropsNumber | IPropsPassword;
|
32
|
+
interface IState {
|
33
|
+
value: string | number;
|
34
|
+
invalid: boolean;
|
35
|
+
}
|
36
|
+
export declare class InputBase extends React.Component<IProps, IState> {
|
37
|
+
constructor(props: IProps);
|
38
|
+
handleChange(event: React.ChangeEvent<HTMLInputElement>): void;
|
39
|
+
componentDidUpdate(prevProps: any): void;
|
40
|
+
render(): JSX.Element;
|
41
|
+
}
|
42
|
+
export {};
|
@@ -0,0 +1,72 @@
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
18
|
+
if (k2 === undefined) k2 = k;
|
19
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
20
|
+
}) : (function(o, m, k, k2) {
|
21
|
+
if (k2 === undefined) k2 = k;
|
22
|
+
o[k2] = m[k];
|
23
|
+
}));
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
26
|
+
}) : function(o, v) {
|
27
|
+
o["default"] = v;
|
28
|
+
});
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
30
|
+
if (mod && mod.__esModule) return mod;
|
31
|
+
var result = {};
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
33
|
+
__setModuleDefault(result, mod);
|
34
|
+
return result;
|
35
|
+
};
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
37
|
+
exports.InputBase = void 0;
|
38
|
+
var React = __importStar(require("react"));
|
39
|
+
var InputBase = /** @class */ (function (_super) {
|
40
|
+
__extends(InputBase, _super);
|
41
|
+
function InputBase(props) {
|
42
|
+
var _a, _b;
|
43
|
+
var _this = _super.call(this, props) || this;
|
44
|
+
_this.state = {
|
45
|
+
value: (_a = _this.props.value) !== null && _a !== void 0 ? _a : '',
|
46
|
+
invalid: (_b = _this.props.invalid) !== null && _b !== void 0 ? _b : false,
|
47
|
+
};
|
48
|
+
_this.handleChange = _this.handleChange.bind(_this);
|
49
|
+
return _this;
|
50
|
+
}
|
51
|
+
// htmlId = nextId();
|
52
|
+
InputBase.prototype.handleChange = function (event) {
|
53
|
+
this.setState({ value: event.target.value });
|
54
|
+
if (this.props.type === 'number') {
|
55
|
+
this.props.onChange(Number(event.target.value));
|
56
|
+
}
|
57
|
+
else {
|
58
|
+
this.props.onChange(event.target.value);
|
59
|
+
}
|
60
|
+
};
|
61
|
+
InputBase.prototype.componentDidUpdate = function (prevProps) {
|
62
|
+
if (prevProps.value !== this.props.value) {
|
63
|
+
this.setState({ value: this.props.value });
|
64
|
+
}
|
65
|
+
};
|
66
|
+
InputBase.prototype.render = function () {
|
67
|
+
var _a;
|
68
|
+
return (React.createElement("input", { className: 'sd-input__input', type: (_a = this.props.type) !== null && _a !== void 0 ? _a : 'text', id: this.props.htmlId, value: this.state.value, "aria-describedby": this.props.htmlId + 'label', tabIndex: this.props.tabIndex, onChange: this.handleChange, placeholder: this.props.placeholder, disabled: this.props.disabled }));
|
69
|
+
};
|
70
|
+
return InputBase;
|
71
|
+
}(React.Component));
|
72
|
+
exports.InputBase = InputBase;
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
interface IPropsBase {
|
3
|
+
label?: string;
|
4
|
+
maxLength?: number;
|
5
|
+
info?: string;
|
6
|
+
inlineLabel?: boolean;
|
7
|
+
labelHidden?: boolean;
|
8
|
+
error?: string;
|
9
|
+
required?: boolean;
|
10
|
+
disabled?: boolean;
|
11
|
+
invalid?: boolean;
|
12
|
+
tabindex?: number;
|
13
|
+
fullWidth?: boolean;
|
14
|
+
boxedStyle?: boolean;
|
15
|
+
boxedLable?: boolean;
|
16
|
+
placeholder?: string;
|
17
|
+
size?: 'medium' | 'large' | 'x-large';
|
18
|
+
}
|
19
|
+
interface IPropsText extends IPropsBase {
|
20
|
+
type: 'text';
|
21
|
+
value: string;
|
22
|
+
onChange(newValue: string): void;
|
23
|
+
}
|
24
|
+
interface IPropsPassword extends IPropsBase {
|
25
|
+
type: 'password';
|
26
|
+
value: string;
|
27
|
+
onChange(newValue: string): void;
|
28
|
+
}
|
29
|
+
interface IPropsNumber extends IPropsBase {
|
30
|
+
type: 'number';
|
31
|
+
value: string;
|
32
|
+
onChange(newValue: string): void;
|
33
|
+
}
|
34
|
+
declare type IProps = IPropsText | IPropsNumber | IPropsPassword;
|
35
|
+
interface IState {
|
36
|
+
value: string;
|
37
|
+
invalid: boolean;
|
38
|
+
}
|
39
|
+
export declare class InputNew extends React.PureComponent<IProps, IState> {
|
40
|
+
constructor(props: IProps);
|
41
|
+
componentDidUpdate(prevProps: any): void;
|
42
|
+
htmlId: string;
|
43
|
+
render(): JSX.Element;
|
44
|
+
}
|
45
|
+
export {};
|
@@ -0,0 +1,73 @@
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
18
|
+
if (k2 === undefined) k2 = k;
|
19
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
20
|
+
}) : (function(o, m, k, k2) {
|
21
|
+
if (k2 === undefined) k2 = k;
|
22
|
+
o[k2] = m[k];
|
23
|
+
}));
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
26
|
+
}) : function(o, v) {
|
27
|
+
o["default"] = v;
|
28
|
+
});
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
30
|
+
if (mod && mod.__esModule) return mod;
|
31
|
+
var result = {};
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
33
|
+
__setModuleDefault(result, mod);
|
34
|
+
return result;
|
35
|
+
};
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
38
|
+
};
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
40
|
+
exports.InputNew = void 0;
|
41
|
+
var React = __importStar(require("react"));
|
42
|
+
var react_id_generator_1 = __importDefault(require("react-id-generator"));
|
43
|
+
var _1 = require(".");
|
44
|
+
var InputNew = /** @class */ (function (_super) {
|
45
|
+
__extends(InputNew, _super);
|
46
|
+
function InputNew(props) {
|
47
|
+
var _a, _b;
|
48
|
+
var _this = _super.call(this, props) || this;
|
49
|
+
_this.htmlId = (0, react_id_generator_1.default)();
|
50
|
+
_this.state = {
|
51
|
+
value: (_a = _this.props.value) !== null && _a !== void 0 ? _a : '',
|
52
|
+
invalid: (_b = _this.props.invalid) !== null && _b !== void 0 ? _b : false,
|
53
|
+
};
|
54
|
+
return _this;
|
55
|
+
}
|
56
|
+
InputNew.prototype.componentDidUpdate = function (prevProps) {
|
57
|
+
if (prevProps.value !== this.props.value) {
|
58
|
+
this.setState({ value: this.props.value });
|
59
|
+
}
|
60
|
+
};
|
61
|
+
InputNew.prototype.render = function () {
|
62
|
+
var _this = this;
|
63
|
+
var _a;
|
64
|
+
return (React.createElement(_1.InputWrapper, { label: this.props.label, error: this.props.error, required: this.props.required, disabled: this.props.disabled, value: this.state.value, invalid: this.state.invalid, info: this.props.info, maxLength: this.props.maxLength, inlineLabel: this.props.inlineLabel, labelHidden: this.props.labelHidden, size: (_a = this.props.size) !== null && _a !== void 0 ? _a : 'medium', fullWidth: this.props.fullWidth, htmlId: this.htmlId, boxedStyle: this.props.boxedStyle, boxedLable: this.props.boxedLable, tabindex: this.props.tabindex },
|
65
|
+
React.createElement(_1.InputBase, { type: "text", onChange: function (value) {
|
66
|
+
_this.setState({ value: value });
|
67
|
+
_this.setState({ invalid: _this.props.maxLength ? value.length > _this.props.maxLength : false });
|
68
|
+
_this.props.onChange(value);
|
69
|
+
}, disabled: this.props.disabled, htmlId: this.htmlId, value: this.state.value, "aria-describedby": this.htmlId + 'label', tabIndex: this.props.tabindex, placeholder: this.props.placeholder })));
|
70
|
+
};
|
71
|
+
return InputNew;
|
72
|
+
}(React.PureComponent));
|
73
|
+
exports.InputNew = InputNew;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
interface IPropsBase {
|
3
|
+
label?: string;
|
4
|
+
children: React.ReactNode;
|
5
|
+
maxLength?: number;
|
6
|
+
info?: string;
|
7
|
+
error?: string;
|
8
|
+
required?: boolean;
|
9
|
+
disabled?: boolean;
|
10
|
+
invalid?: boolean;
|
11
|
+
inlineLabel?: boolean;
|
12
|
+
labelHidden?: boolean;
|
13
|
+
tabindex?: number;
|
14
|
+
fullWidth?: boolean;
|
15
|
+
boxedStyle?: boolean;
|
16
|
+
boxedLable?: boolean;
|
17
|
+
value?: string | number;
|
18
|
+
htmlId?: string;
|
19
|
+
size?: 'medium' | 'large' | 'x-large';
|
20
|
+
}
|
21
|
+
interface IState {
|
22
|
+
value: string | number;
|
23
|
+
}
|
24
|
+
export declare class InputWrapper extends React.Component<IPropsBase, IState> {
|
25
|
+
constructor(props: IPropsBase);
|
26
|
+
render(): JSX.Element;
|
27
|
+
}
|
28
|
+
export {};
|
@@ -0,0 +1,91 @@
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
18
|
+
if (k2 === undefined) k2 = k;
|
19
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
20
|
+
}) : (function(o, m, k, k2) {
|
21
|
+
if (k2 === undefined) k2 = k;
|
22
|
+
o[k2] = m[k];
|
23
|
+
}));
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
26
|
+
}) : function(o, v) {
|
27
|
+
o["default"] = v;
|
28
|
+
});
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
30
|
+
if (mod && mod.__esModule) return mod;
|
31
|
+
var result = {};
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
33
|
+
__setModuleDefault(result, mod);
|
34
|
+
return result;
|
35
|
+
};
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
38
|
+
};
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
40
|
+
exports.InputWrapper = void 0;
|
41
|
+
var React = __importStar(require("react"));
|
42
|
+
var classnames_1 = __importDefault(require("classnames"));
|
43
|
+
var InputWrapper = /** @class */ (function (_super) {
|
44
|
+
__extends(InputWrapper, _super);
|
45
|
+
function InputWrapper(props) {
|
46
|
+
var _a;
|
47
|
+
var _this = _super.call(this, props) || this;
|
48
|
+
_this.state = {
|
49
|
+
value: (_a = _this.props.value) !== null && _a !== void 0 ? _a : '',
|
50
|
+
};
|
51
|
+
return _this;
|
52
|
+
}
|
53
|
+
InputWrapper.prototype.render = function () {
|
54
|
+
var _a;
|
55
|
+
var _b;
|
56
|
+
var classes = (0, classnames_1.default)('sd-input', (_a = {
|
57
|
+
'sd-input--inline-label': this.props.inlineLabel,
|
58
|
+
'sd-input--required': this.props.required,
|
59
|
+
'sd-input--disabled': this.props.disabled,
|
60
|
+
'sd-input--full-width': this.props.fullWidth,
|
61
|
+
'sd-input--invalid': this.props.invalid,
|
62
|
+
'sd-input--medium': this.props.size === undefined
|
63
|
+
},
|
64
|
+
_a["sd-input--".concat(this.props.size)] = this.props.size || this.props.size !== undefined,
|
65
|
+
_a['sd-input--boxed-style'] = this.props.boxedStyle,
|
66
|
+
_a['sd-input--boxed-label'] = this.props.boxedLable,
|
67
|
+
_a));
|
68
|
+
var labelClasses = (0, classnames_1.default)('sd-input__label', {
|
69
|
+
'a11y-only': this.props.labelHidden,
|
70
|
+
'sd-input__label--boxed': this.props.boxedLable,
|
71
|
+
});
|
72
|
+
return (React.createElement("div", { className: classes },
|
73
|
+
React.createElement("label", { className: labelClasses, htmlFor: this.props.htmlId, id: this.props.htmlId + 'label', tabIndex: this.props.tabindex === undefined ? undefined : -1 }, this.props.label),
|
74
|
+
React.createElement("div", { className: "sd-input__input-container" }, this.props.children),
|
75
|
+
this.props.maxLength
|
76
|
+
? React.createElement("div", { className: 'sd-input__char-count' }, (_b = this.props.value) === null || _b === void 0 ? void 0 :
|
77
|
+
_b.toString().length,
|
78
|
+
" / ",
|
79
|
+
this.props.maxLength)
|
80
|
+
: null,
|
81
|
+
React.createElement("div", { className: 'sd-input__message-box' },
|
82
|
+
this.props.info && !this.props.invalid && !this.props.invalid
|
83
|
+
? React.createElement("div", { className: 'sd-input__hint' }, this.props.info)
|
84
|
+
: null,
|
85
|
+
this.props.invalid || this.props.invalid
|
86
|
+
? React.createElement("div", { className: 'sd-input__message' }, this.props.error)
|
87
|
+
: null)));
|
88
|
+
};
|
89
|
+
return InputWrapper;
|
90
|
+
}(React.Component));
|
91
|
+
exports.InputWrapper = InputWrapper;
|
@@ -3,3 +3,6 @@ export { FormGroup } from './FormGroup';
|
|
3
3
|
export { FormItem } from './FormItem';
|
4
4
|
export { FormText } from './FormText';
|
5
5
|
export { FormLabel } from './FormLabel';
|
6
|
+
export { InputWrapper } from './InputWrapper';
|
7
|
+
export { InputBase } from './InputBase';
|
8
|
+
export { InputNew } from './InputNew';
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.FormLabel = exports.FormText = exports.FormItem = exports.FormGroup = exports.FormRow = void 0;
|
3
|
+
exports.InputNew = exports.InputBase = exports.InputWrapper = exports.FormLabel = exports.FormText = exports.FormItem = exports.FormGroup = exports.FormRow = void 0;
|
4
4
|
var FormRow_1 = require("./FormRow");
|
5
5
|
Object.defineProperty(exports, "FormRow", { enumerable: true, get: function () { return FormRow_1.FormRow; } });
|
6
6
|
var FormGroup_1 = require("./FormGroup");
|
@@ -11,3 +11,9 @@ var FormText_1 = require("./FormText");
|
|
11
11
|
Object.defineProperty(exports, "FormText", { enumerable: true, get: function () { return FormText_1.FormText; } });
|
12
12
|
var FormLabel_1 = require("./FormLabel");
|
13
13
|
Object.defineProperty(exports, "FormLabel", { enumerable: true, get: function () { return FormLabel_1.FormLabel; } });
|
14
|
+
var InputWrapper_1 = require("./InputWrapper");
|
15
|
+
Object.defineProperty(exports, "InputWrapper", { enumerable: true, get: function () { return InputWrapper_1.InputWrapper; } });
|
16
|
+
var InputBase_1 = require("./InputBase");
|
17
|
+
Object.defineProperty(exports, "InputBase", { enumerable: true, get: function () { return InputBase_1.InputBase; } });
|
18
|
+
var InputNew_1 = require("./InputNew");
|
19
|
+
Object.defineProperty(exports, "InputNew", { enumerable: true, get: function () { return InputNew_1.InputNew; } });
|