carbon-react 106.0.1 → 106.1.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.
- package/esm/__internal__/input/index.d.ts +5 -5
- package/esm/__internal__/input/input-presentation.component.d.ts +21 -27
- package/esm/__internal__/input/input-presentation.component.js +7 -20
- package/esm/__internal__/input/input-presentation.style.d.ts +5 -8
- package/esm/__internal__/input/input-presentation.style.js +37 -53
- package/esm/__internal__/input/input-sizes.style.d.ts +8 -18
- package/esm/__internal__/input/input-sizes.style.js +3 -2
- package/esm/__internal__/input/input.component.d.ts +39 -2
- package/esm/__internal__/input/input.component.js +84 -66
- package/esm/__internal__/input/input.style.d.ts +2 -1
- package/esm/__internal__/input/input.style.js +0 -4
- package/esm/__internal__/input-behaviour/index.d.ts +2 -1
- package/esm/__internal__/input-behaviour/input-behaviour.component.d.ts +7 -10
- package/esm/__internal__/input-behaviour/input-behaviour.component.js +2 -7
- package/esm/__internal__/input-behaviour/input-group-behaviour.component.d.ts +8 -12
- package/esm/__internal__/input-behaviour/input-group-behaviour.component.js +1 -7
- package/esm/__internal__/input-behaviour/useInputBehaviour.d.ts +14 -10
- package/esm/__internal__/label/label.d.ts +1 -1
- package/esm/components/badge/badge.component.d.ts +10 -13
- package/esm/components/badge/badge.component.js +60 -24
- package/esm/components/badge/badge.style.d.ts +7 -5
- package/esm/components/badge/index.d.ts +2 -1
- package/esm/components/carbon-provider/carbon-provider.component.d.ts +8 -14
- package/esm/components/carbon-provider/carbon-provider.component.js +110 -14
- package/esm/components/carbon-provider/index.d.ts +2 -1
- package/esm/components/date-range/date-range.style.js +2 -2
- package/esm/components/decimal/decimal.component.js +2 -1
- package/esm/components/heading/heading.style.d.ts +1 -2
- package/esm/components/inline-inputs/index.d.ts +2 -1
- package/esm/components/inline-inputs/index.js +1 -1
- package/esm/components/inline-inputs/inline-inputs.component.d.ts +25 -22
- package/esm/components/inline-inputs/inline-inputs.component.js +96 -60
- package/esm/components/inline-inputs/inline-inputs.config.d.ts +1 -1
- package/esm/components/inline-inputs/inline-inputs.style.d.ts +5 -3
- package/esm/components/inline-inputs/inline-inputs.style.js +2 -2
- package/esm/components/link/index.d.ts +1 -2
- package/esm/components/link/link.component.d.ts +37 -2
- package/esm/components/link/link.component.js +1243 -124
- package/esm/components/link/link.config.d.ts +2 -2
- package/esm/components/link/link.style.d.ts +7 -2
- package/esm/components/link/link.style.js +0 -5
- package/esm/components/pager/pager.style.d.ts +1 -2
- package/esm/components/pod/pod.style.d.ts +1 -2
- package/esm/components/simple-color-picker/simple-color-input/simple-color-input.style.d.ts +1 -1
- package/esm/components/split-button/index.d.ts +1 -0
- package/esm/components/text-editor/__internal__/editor-link/editor-link.style.d.ts +1 -2
- package/esm/components/textarea/textarea-test.stories.js +21 -1
- package/esm/components/tile-select/tile-select.style.d.ts +1 -1
- package/esm/style/fonts.css +22 -16
- package/lib/__internal__/input/index.d.ts +5 -5
- package/lib/__internal__/input/input-presentation.component.d.ts +21 -27
- package/lib/__internal__/input/input-presentation.component.js +7 -23
- package/lib/__internal__/input/input-presentation.style.d.ts +5 -8
- package/lib/__internal__/input/input-presentation.style.js +37 -54
- package/lib/__internal__/input/input-sizes.style.d.ts +8 -18
- package/lib/__internal__/input/input-sizes.style.js +2 -1
- package/lib/__internal__/input/input.component.d.ts +39 -2
- package/lib/__internal__/input/input.component.js +85 -69
- package/lib/__internal__/input/input.style.d.ts +2 -1
- package/lib/__internal__/input/input.style.js +0 -7
- package/lib/__internal__/input-behaviour/index.d.ts +2 -1
- package/lib/__internal__/input-behaviour/input-behaviour.component.d.ts +7 -10
- package/lib/__internal__/input-behaviour/input-behaviour.component.js +3 -10
- package/lib/__internal__/input-behaviour/input-group-behaviour.component.d.ts +8 -12
- package/lib/__internal__/input-behaviour/input-group-behaviour.component.js +2 -10
- package/lib/__internal__/input-behaviour/useInputBehaviour.d.ts +14 -10
- package/lib/__internal__/label/label.d.ts +1 -1
- package/lib/components/badge/badge.component.d.ts +10 -13
- package/lib/components/badge/badge.component.js +51 -29
- package/lib/components/badge/badge.style.d.ts +7 -5
- package/lib/components/badge/index.d.ts +2 -1
- package/lib/components/carbon-provider/carbon-provider.component.d.ts +8 -14
- package/lib/components/carbon-provider/carbon-provider.component.js +115 -20
- package/lib/components/carbon-provider/index.d.ts +2 -1
- package/lib/components/date-range/date-range.style.js +4 -4
- package/lib/components/decimal/decimal.component.js +2 -1
- package/lib/components/heading/heading.style.d.ts +1 -2
- package/lib/components/inline-inputs/index.d.ts +2 -1
- package/lib/components/inline-inputs/index.js +10 -2
- package/lib/components/inline-inputs/inline-inputs.component.d.ts +25 -22
- package/lib/components/inline-inputs/inline-inputs.component.js +143 -68
- package/lib/components/inline-inputs/inline-inputs.config.d.ts +1 -1
- package/lib/components/inline-inputs/inline-inputs.style.d.ts +5 -3
- package/lib/components/inline-inputs/inline-inputs.style.js +2 -2
- package/lib/components/link/index.d.ts +1 -2
- package/lib/components/link/link.component.d.ts +37 -2
- package/lib/components/link/link.component.js +764 -146
- package/lib/components/link/link.config.d.ts +2 -2
- package/lib/components/link/link.style.d.ts +7 -2
- package/lib/components/link/link.style.js +0 -6
- package/lib/components/pager/pager.style.d.ts +1 -2
- package/lib/components/pod/pod.style.d.ts +1 -2
- package/lib/components/simple-color-picker/simple-color-input/simple-color-input.style.d.ts +1 -1
- package/lib/components/split-button/index.d.ts +1 -0
- package/lib/components/text-editor/__internal__/editor-link/editor-link.style.d.ts +1 -2
- package/lib/components/textarea/textarea-test.stories.js +21 -1
- package/lib/components/tile-select/tile-select.style.d.ts +1 -1
- package/lib/style/fonts.css +22 -16
- package/package.json +1 -2
- package/esm/__internal__/input/extract-props/extract-props.d.ts +0 -1
- package/esm/__internal__/input/extract-props/extract-props.js +0 -11
- package/esm/__internal__/input/extract-props/index.d.ts +0 -1
- package/esm/__internal__/input/extract-props/index.js +0 -1
- package/esm/__internal__/input/input-presentation.d.ts +0 -24
- package/esm/__internal__/input/input.d.ts +0 -54
- package/esm/components/badge/badge.d.ts +0 -14
- package/esm/components/carbon-provider/carbon-provider.d.ts +0 -12
- package/esm/components/inline-inputs/inline-inputs.d.ts +0 -30
- package/esm/components/link/link.d.ts +0 -47
- package/lib/__internal__/input/extract-props/extract-props.d.ts +0 -1
- package/lib/__internal__/input/extract-props/extract-props.js +0 -18
- package/lib/__internal__/input/extract-props/index.d.ts +0 -1
- package/lib/__internal__/input/extract-props/index.js +0 -15
- package/lib/__internal__/input/extract-props/package.json +0 -6
- package/lib/__internal__/input/input-presentation.d.ts +0 -24
- package/lib/__internal__/input/input.d.ts +0 -54
- package/lib/components/badge/badge.d.ts +0 -14
- package/lib/components/carbon-provider/carbon-provider.d.ts +0 -12
- package/lib/components/inline-inputs/inline-inputs.d.ts +0 -30
- package/lib/components/link/link.d.ts +0 -47
|
@@ -7,9 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _input = _interopRequireDefault(require("./input.style"));
|
|
10
|
+
var _input2 = _interopRequireDefault(require("./input.style"));
|
|
13
11
|
|
|
14
12
|
var _inputBehaviour = require("../input-behaviour");
|
|
15
13
|
|
|
@@ -21,6 +19,28 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
21
19
|
|
|
22
20
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
21
|
|
|
22
|
+
function selectTextOnFocus(input) {
|
|
23
|
+
// setTimeout is required so the dom has a chance to place the cursor in the input
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
if (input !== null && input !== void 0 && input.current) {
|
|
26
|
+
const {
|
|
27
|
+
selectionStart,
|
|
28
|
+
selectionEnd,
|
|
29
|
+
value
|
|
30
|
+
} = input.current;
|
|
31
|
+
const {
|
|
32
|
+
length
|
|
33
|
+
} = value; // only select text if cursor is at the very end or the very start of the value
|
|
34
|
+
|
|
35
|
+
if (selectionStart === 0 && selectionEnd === 0 || selectionStart === length && selectionEnd === length) {
|
|
36
|
+
if (document.activeElement === input.current) {
|
|
37
|
+
input.current.setSelectionRange(0, length);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
24
44
|
const Input = /*#__PURE__*/_react.default.forwardRef(({
|
|
25
45
|
align,
|
|
26
46
|
placeholder,
|
|
@@ -43,59 +63,95 @@ const Input = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
43
63
|
const groupContext = (0, _react.useContext)(_inputBehaviour.InputGroupContext);
|
|
44
64
|
const deferredTimeout = (0, _react.useRef)(null);
|
|
45
65
|
let input = (0, _react.useRef)(null);
|
|
46
|
-
|
|
66
|
+
|
|
67
|
+
if (ref) {
|
|
68
|
+
input = ref;
|
|
69
|
+
}
|
|
70
|
+
|
|
47
71
|
(0, _react.useEffect)(() => {
|
|
48
|
-
if (autoFocus && input.current)
|
|
72
|
+
if (autoFocus && input.current) {
|
|
73
|
+
input.current.focus();
|
|
74
|
+
}
|
|
49
75
|
}, [autoFocus, input]);
|
|
50
76
|
(0, _react.useEffect)(() => {
|
|
51
|
-
if (inputRef)
|
|
77
|
+
if (inputRef) {
|
|
78
|
+
inputRef(input);
|
|
79
|
+
}
|
|
52
80
|
}, [input, inputRef]);
|
|
53
81
|
(0, _react.useEffect)(() => {
|
|
54
|
-
if (context.inputRef)
|
|
82
|
+
if (context.inputRef) {
|
|
83
|
+
context.inputRef(input);
|
|
84
|
+
}
|
|
55
85
|
}, [context, input]);
|
|
56
86
|
(0, _react.useEffect)(() => {
|
|
57
|
-
if (disabled && context.onBlur)
|
|
87
|
+
if (disabled && context.onBlur) {
|
|
88
|
+
context.onBlur();
|
|
89
|
+
}
|
|
58
90
|
}, [disabled, context]);
|
|
59
91
|
|
|
60
92
|
const handleClick = ev => {
|
|
61
|
-
|
|
62
|
-
|
|
93
|
+
var _input, _input$current;
|
|
94
|
+
|
|
95
|
+
if (onClick) {
|
|
96
|
+
onClick(ev);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
(_input = input) === null || _input === void 0 ? void 0 : (_input$current = _input.current) === null || _input$current === void 0 ? void 0 : _input$current.focus();
|
|
63
100
|
};
|
|
64
101
|
|
|
65
102
|
const handleFocus = ev => {
|
|
66
|
-
if (onFocus)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
103
|
+
if (onFocus) {
|
|
104
|
+
onFocus(ev);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (context.onFocus) {
|
|
108
|
+
context.onFocus();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (groupContext.onFocus) {
|
|
112
|
+
groupContext.onFocus();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (type === "text") {
|
|
116
|
+
selectTextOnFocus(input);
|
|
117
|
+
}
|
|
70
118
|
};
|
|
71
119
|
|
|
72
120
|
const handleBlur = ev => {
|
|
73
|
-
if (onBlur)
|
|
74
|
-
|
|
75
|
-
|
|
121
|
+
if (onBlur) {
|
|
122
|
+
onBlur(ev);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (context.onBlur) {
|
|
126
|
+
context.onBlur();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (groupContext.onBlur) {
|
|
130
|
+
groupContext.onBlur();
|
|
131
|
+
}
|
|
76
132
|
};
|
|
77
133
|
|
|
78
|
-
const handleDeferred =
|
|
79
|
-
currentTarget,
|
|
80
|
-
target
|
|
81
|
-
}) => {
|
|
134
|
+
const handleDeferred = ev => {
|
|
82
135
|
if (onChangeDeferred) {
|
|
83
|
-
|
|
136
|
+
if (deferredTimeout.current) {
|
|
137
|
+
clearTimeout(deferredTimeout.current);
|
|
138
|
+
}
|
|
139
|
+
|
|
84
140
|
deferredTimeout.current = setTimeout(() => {
|
|
85
|
-
onChangeDeferred(
|
|
86
|
-
currentTarget,
|
|
87
|
-
target
|
|
88
|
-
});
|
|
141
|
+
onChangeDeferred(ev);
|
|
89
142
|
}, deferTimeout || 750);
|
|
90
143
|
}
|
|
91
144
|
};
|
|
92
145
|
|
|
93
146
|
const handleChange = ev => {
|
|
94
|
-
if (onChange)
|
|
147
|
+
if (onChange) {
|
|
148
|
+
onChange(ev);
|
|
149
|
+
}
|
|
150
|
+
|
|
95
151
|
handleDeferred(ev);
|
|
96
152
|
};
|
|
97
153
|
|
|
98
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
154
|
+
return /*#__PURE__*/_react.default.createElement(_input2.default, _extends({}, rest, {
|
|
99
155
|
"aria-labelledby": context.ariaLabelledBy,
|
|
100
156
|
align: align,
|
|
101
157
|
placeholder: placeholder,
|
|
@@ -113,46 +169,6 @@ const Input = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
113
169
|
}));
|
|
114
170
|
});
|
|
115
171
|
|
|
116
|
-
Input.
|
|
117
|
-
align: _propTypes.default.oneOf(["right", "left"]),
|
|
118
|
-
placeholder: _propTypes.default.string,
|
|
119
|
-
disabled: _propTypes.default.bool,
|
|
120
|
-
readOnly: _propTypes.default.bool,
|
|
121
|
-
className: _propTypes.default.string,
|
|
122
|
-
id: _propTypes.default.string,
|
|
123
|
-
|
|
124
|
-
/** A callback to retrieve the input reference */
|
|
125
|
-
inputRef: _propTypes.default.func,
|
|
126
|
-
name: _propTypes.default.string,
|
|
127
|
-
onBlur: _propTypes.default.func,
|
|
128
|
-
onClick: _propTypes.default.func,
|
|
129
|
-
onKeyDown: _propTypes.default.func,
|
|
130
|
-
onFocus: _propTypes.default.func,
|
|
131
|
-
autoFocus: _propTypes.default.bool,
|
|
132
|
-
onChange: _propTypes.default.func,
|
|
133
|
-
onChangeDeferred: _propTypes.default.func,
|
|
134
|
-
deferTimeout: _propTypes.default.number,
|
|
135
|
-
type: _propTypes.default.string
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
function selectTextOnFocus(input) {
|
|
139
|
-
// setTimeout is required so the dom has a chance to place the cursor in the input
|
|
140
|
-
setTimeout(() => {
|
|
141
|
-
if (input.current) {
|
|
142
|
-
const {
|
|
143
|
-
length
|
|
144
|
-
} = input.current.value;
|
|
145
|
-
const cursorStart = input.current.selectionStart;
|
|
146
|
-
const cursorEnd = input.current.selectionEnd; // only select text if cursor is at the very end or the very start of the value
|
|
147
|
-
|
|
148
|
-
if (cursorStart === 0 && cursorEnd === 0 || cursorStart === length && cursorEnd === length) {
|
|
149
|
-
if (document.activeElement === input.current) {
|
|
150
|
-
input.current.setSelectionRange(0, length);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
172
|
+
Input.displayName = "Input";
|
|
157
173
|
var _default = Input;
|
|
158
174
|
exports.default = _default;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { CommonInputProps } from "./input.component";
|
|
2
|
+
declare const StyledInput: import("styled-components").StyledComponent<"input", any, Pick<CommonInputProps, "disabled" | "align" | "readOnly">, never>;
|
|
1
3
|
export default StyledInput;
|
|
2
|
-
declare const StyledInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
@@ -7,10 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
15
11
|
|
|
16
12
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -54,8 +50,5 @@ const StyledInput = _styledComponents.default.input`
|
|
|
54
50
|
color: var(--colorsActionMinorYin090);
|
|
55
51
|
`}
|
|
56
52
|
`;
|
|
57
|
-
StyledInput.propTypes = {
|
|
58
|
-
disabled: _propTypes.default.bool
|
|
59
|
-
};
|
|
60
53
|
var _default = StyledInput;
|
|
61
54
|
exports.default = _default;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { InputBehaviour, InputContext } from "./input-behaviour.component";
|
|
2
|
-
export { InputGroupBehaviour, InputGroupContext } from "./input-group-behaviour.component";
|
|
2
|
+
export { InputGroupBehaviour, InputGroupContext, } from "./input-group-behaviour.component";
|
|
3
|
+
export type { InputContextProps } from "./useInputBehaviour";
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
export const InputContext: React.Context<{}>;
|
|
2
|
-
export function InputBehaviour({ children }: {
|
|
3
|
-
children: any;
|
|
4
|
-
}): JSX.Element;
|
|
5
|
-
export namespace InputBehaviour {
|
|
6
|
-
namespace propTypes {
|
|
7
|
-
const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
1
|
import React from "react";
|
|
11
|
-
import
|
|
2
|
+
import { InputContextProps } from "./useInputBehaviour";
|
|
3
|
+
declare const InputContext: React.Context<InputContextProps>;
|
|
4
|
+
export interface InputBehaviourProps {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
declare const InputBehaviour: ({ children }: InputBehaviourProps) => JSX.Element;
|
|
8
|
+
export { InputContext, InputBehaviour };
|
|
@@ -7,9 +7,7 @@ exports.InputBehaviour = exports.InputContext = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _inlineInputs = require("../../components/inline-inputs/inline-inputs.component");
|
|
10
|
+
var _inlineInputs = require("../../components/inline-inputs");
|
|
13
11
|
|
|
14
12
|
var _useInputBehaviour = _interopRequireDefault(require("./useInputBehaviour"));
|
|
15
13
|
|
|
@@ -19,9 +17,7 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
19
17
|
|
|
20
18
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
19
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const InputContext = /*#__PURE__*/_react.default.createContext(defaultValue);
|
|
20
|
+
const InputContext = /*#__PURE__*/_react.default.createContext({});
|
|
25
21
|
|
|
26
22
|
exports.InputContext = InputContext;
|
|
27
23
|
|
|
@@ -39,7 +35,4 @@ const InputBehaviour = ({
|
|
|
39
35
|
}, children);
|
|
40
36
|
};
|
|
41
37
|
|
|
42
|
-
exports.InputBehaviour = InputBehaviour;
|
|
43
|
-
InputBehaviour.propTypes = {
|
|
44
|
-
children: _propTypes.default.node
|
|
45
|
-
};
|
|
38
|
+
exports.InputBehaviour = InputBehaviour;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
export const InputGroupContext: React.Context<{}>;
|
|
2
|
-
export function InputGroupBehaviour({ children, blockGroupBehaviour }: {
|
|
3
|
-
children: any;
|
|
4
|
-
blockGroupBehaviour: any;
|
|
5
|
-
}): JSX.Element;
|
|
6
|
-
export namespace InputGroupBehaviour {
|
|
7
|
-
namespace propTypes {
|
|
8
|
-
const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
9
|
-
const blockGroupBehaviour: PropTypes.Requireable<boolean>;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
1
|
import React from "react";
|
|
13
|
-
import
|
|
2
|
+
import { InputContextProps } from "./useInputBehaviour";
|
|
3
|
+
import { InputBehaviourProps } from "./input-behaviour.component";
|
|
4
|
+
declare const InputGroupContext: React.Context<InputContextProps>;
|
|
5
|
+
export interface InputGroupBehaviourProps extends InputBehaviourProps {
|
|
6
|
+
blockGroupBehaviour?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const InputGroupBehaviour: ({ children, blockGroupBehaviour, }: InputGroupBehaviourProps) => JSX.Element;
|
|
9
|
+
export { InputGroupContext, InputGroupBehaviour };
|
|
@@ -7,15 +7,11 @@ exports.InputGroupBehaviour = exports.InputGroupContext = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
10
|
var _useInputBehaviour = _interopRequireDefault(require("./useInputBehaviour"));
|
|
13
11
|
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
13
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const InputGroupContext = /*#__PURE__*/_react.default.createContext(defaultValue);
|
|
14
|
+
const InputGroupContext = /*#__PURE__*/_react.default.createContext({});
|
|
19
15
|
|
|
20
16
|
exports.InputGroupContext = InputGroupContext;
|
|
21
17
|
|
|
@@ -29,8 +25,4 @@ const InputGroupBehaviour = ({
|
|
|
29
25
|
}, children);
|
|
30
26
|
};
|
|
31
27
|
|
|
32
|
-
exports.InputGroupBehaviour = InputGroupBehaviour;
|
|
33
|
-
InputGroupBehaviour.propTypes = {
|
|
34
|
-
children: _propTypes.default.node,
|
|
35
|
-
blockGroupBehaviour: _propTypes.default.bool
|
|
36
|
-
};
|
|
28
|
+
exports.InputGroupBehaviour = InputGroupBehaviour;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
export interface InputContextProps {
|
|
2
|
+
hasFocus?: boolean;
|
|
3
|
+
hasMouseOver?: boolean;
|
|
4
|
+
onFocus?: () => void;
|
|
5
|
+
onBlur?: () => void;
|
|
6
|
+
onMouseDown?: () => void;
|
|
7
|
+
onMouseEnter?: () => void;
|
|
8
|
+
onMouseLeave?: () => void;
|
|
9
|
+
inputRef?: (input: {
|
|
10
|
+
current: HTMLInputElement | null;
|
|
11
|
+
}) => void;
|
|
12
|
+
ariaLabelledBy?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const useInputBehaviour: (blockGroupBehaviour?: boolean | undefined) => InputContextProps;
|
|
1
15
|
export default useInputBehaviour;
|
|
2
|
-
declare function useInputBehaviour(blockGroupBehaviour: any): {
|
|
3
|
-
hasFocus: boolean;
|
|
4
|
-
hasMouseOver: boolean;
|
|
5
|
-
onFocus: (() => void) | undefined;
|
|
6
|
-
onBlur: (() => void) | undefined;
|
|
7
|
-
onMouseDown: () => void;
|
|
8
|
-
onMouseEnter: (() => void) | undefined;
|
|
9
|
-
onMouseLeave: (() => void) | undefined;
|
|
10
|
-
inputRef: (input: any) => void;
|
|
11
|
-
};
|
|
@@ -29,7 +29,7 @@ export interface LabelPropTypes extends ValidationPropTypes {
|
|
|
29
29
|
/** Whether to show the validation icon */
|
|
30
30
|
useValidationIcon?: boolean;
|
|
31
31
|
/** A string that represents the ID of another form element */
|
|
32
|
-
htmlFor
|
|
32
|
+
htmlFor?: string;
|
|
33
33
|
/** Padding right, integer multiplied by base spacing constant (8) */
|
|
34
34
|
pr?: 1 | 2;
|
|
35
35
|
/** Padding left, integer multiplied by base spacing constant (8) */
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
10
|
-
const counter: PropTypes.Requireable<string | number>;
|
|
11
|
-
const onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
12
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface BadgeProps {
|
|
3
|
+
/** The badge will be added to this element */
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/** The number rendered in the badge component */
|
|
6
|
+
counter?: string | number;
|
|
7
|
+
/** Callback fired when badge is clicked */
|
|
8
|
+
onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
13
9
|
}
|
|
14
|
-
|
|
10
|
+
export declare const Badge: ({ children, counter, onClick }: BadgeProps) => JSX.Element;
|
|
11
|
+
export default Badge;
|
|
@@ -1,44 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
4
|
+
value: true,
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
exports.default = exports.Badge = void 0;
|
|
9
8
|
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
12
|
var _badge = require("./badge.style");
|
|
13
13
|
|
|
14
|
-
function _interopRequireDefault(obj) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
function _interopRequireDefault(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const Badge = ({ children, counter = 0, onClick }) => {
|
|
19
|
+
return /*#__PURE__*/ _react.default.createElement(
|
|
20
|
+
_badge.StyledBadgeWrapper,
|
|
21
|
+
null,
|
|
22
|
+
counter > 0 &&
|
|
23
|
+
/*#__PURE__*/ _react.default.createElement(
|
|
24
|
+
_badge.StyledButton,
|
|
25
|
+
{
|
|
26
|
+
"data-component": "badge",
|
|
27
|
+
buttonType: "secondary",
|
|
28
|
+
onClick: onClick,
|
|
29
|
+
},
|
|
30
|
+
/*#__PURE__*/ _react.default.createElement(_badge.StyledCrossIcon, {
|
|
31
|
+
"data-element": "badge-cross-icon",
|
|
32
|
+
type: "cross",
|
|
33
|
+
}),
|
|
34
|
+
/*#__PURE__*/ _react.default.createElement(
|
|
35
|
+
_badge.StyledCounter,
|
|
36
|
+
{
|
|
37
|
+
"data-element": "badge-counter",
|
|
38
|
+
},
|
|
39
|
+
counter > 99 ? 99 : counter
|
|
40
|
+
)
|
|
41
|
+
),
|
|
42
|
+
children
|
|
43
|
+
);
|
|
31
44
|
};
|
|
32
45
|
|
|
33
46
|
Badge.propTypes = {
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The badge will be added to this element
|
|
49
|
+
*/
|
|
50
|
+
children: _propTypes.default.node,
|
|
51
|
+
/**
|
|
52
|
+
* The number rendered in the badge component
|
|
53
|
+
*/
|
|
54
|
+
counter: _propTypes.default.oneOfType([
|
|
55
|
+
_propTypes.default.number,
|
|
56
|
+
_propTypes.default.string,
|
|
57
|
+
]),
|
|
58
|
+
/**
|
|
59
|
+
* Callback fired when badge is clicked
|
|
60
|
+
*/
|
|
61
|
+
onClick: _propTypes.default.func,
|
|
42
62
|
};
|
|
63
|
+
|
|
64
|
+
exports.Badge = Badge;
|
|
43
65
|
var _default = Badge;
|
|
44
|
-
exports.default = _default;
|
|
66
|
+
exports.default = _default;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import Icon from "../icon";
|
|
3
|
+
declare const StyledBadgeWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
declare const StyledCounter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
declare const StyledButton: import("styled-components").StyledComponent<{
|
|
3
6
|
({ size, subtext, as, children, forwardRef, "aria-label": ariaLabel, disabled, destructive, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, fullWidth, ...rest }: import("../button").ButtonProps): JSX.Element;
|
|
4
7
|
displayName: string;
|
|
5
8
|
}, any, {}, never>;
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
import Icon from "../icon";
|
|
9
|
+
declare const StyledCrossIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
|
|
10
|
+
export { StyledBadgeWrapper, StyledButton, StyledCrossIcon, StyledCounter };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./badge";
|
|
1
|
+
export { default } from "./badge.component";
|
|
2
|
+
export type { BadgeProps } from "./badge.component";
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
export const NewValidationContext: React.Context<{}>;
|
|
2
|
-
export default CarbonProvider;
|
|
3
1
|
import React from "react";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
theme?:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declare namespace CarbonProvider {
|
|
10
|
-
namespace propTypes {
|
|
11
|
-
const children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
12
|
-
const theme: PropTypes.Requireable<object>;
|
|
13
|
-
const validationRedesignOptIn: PropTypes.Requireable<boolean>;
|
|
14
|
-
}
|
|
2
|
+
import { ThemeObject } from "../../style/themes/base";
|
|
3
|
+
export interface CarbonProviderProps {
|
|
4
|
+
theme?: ThemeObject;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
validationRedesignOptIn?: boolean;
|
|
15
7
|
}
|
|
16
|
-
|
|
8
|
+
export declare const NewValidationContext: React.Context<Pick<CarbonProviderProps, "validationRedesignOptIn">>;
|
|
9
|
+
export declare const CarbonProvider: ({ children, theme, validationRedesignOptIn, }: CarbonProviderProps) => JSX.Element;
|
|
10
|
+
export default CarbonProvider;
|