@skyscanner/backpack-web 34.16.0 → 35.0.0-premajor.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bpk-component-button/src/BpkButtonDestructive.module.css +18 -0
- package/bpk-component-button/src/BpkButtonFeatured.module.css +18 -0
- package/bpk-component-button/src/BpkButtonLink.module.css +18 -0
- package/bpk-component-button/src/BpkButtonLinkOnDark.module.css +18 -0
- package/bpk-component-button/src/BpkButtonPrimaryOnDark.module.css +18 -0
- package/bpk-component-button/src/BpkButtonPrimaryOnLight.module.css +18 -0
- package/bpk-component-button/src/BpkButtonSecondary.module.css +18 -0
- package/bpk-component-button/src/BpkButtonSecondaryOnDark.module.css +18 -0
- package/bpk-component-close-button/src/BpkCloseButton.d.ts +10 -0
- package/bpk-component-close-button/src/BpkCloseButton.js +21 -37
- package/bpk-component-datepicker/src/BpkDatepicker.module.css +18 -0
- package/bpk-component-flare/src/__generated__/js/corner-radius.d.ts +5 -0
- package/bpk-component-flare/src/__generated__/js/pointer.d.ts +5 -0
- package/bpk-component-input/src/BpkClearButton.module.css +18 -0
- package/bpk-component-input/src/BpkInput.js +1 -1
- package/bpk-component-input/src/common-types.d.ts +1 -1
- package/bpk-component-loading-button/src/BpkLoadingButton.d.ts +6 -38
- package/bpk-component-loading-button/src/BpkLoadingButton.js +13 -44
- package/bpk-component-navigation-bar/src/BpkNavigationBarButtonLink.module.css +18 -0
- package/bpk-component-nudger/index.d.ts +1 -2
- package/bpk-component-nudger/index.js +1 -2
- package/bpk-component-nudger/src/BpkNudger.d.ts +1 -1
- package/bpk-component-nudger/src/BpkNudger.js +102 -20
- package/bpk-component-nudger/src/BpkNudger.module.css +1 -1
- package/bpk-component-nudger/src/common-types.d.ts +7 -5
- package/bpk-component-slider/src/BpkSlider.d.ts +4 -1
- package/bpk-component-slider/src/BpkSlider.js +51 -3
- package/bpk-component-spinner/src/BpkExtraLargeSpinner.d.ts +4 -14
- package/bpk-component-spinner/src/BpkExtraLargeSpinner.js +5 -16
- package/bpk-component-spinner/src/BpkLargeSpinner.d.ts +5 -17
- package/bpk-component-spinner/src/BpkLargeSpinner.js +6 -19
- package/bpk-component-spinner/src/BpkSpinner.d.ts +5 -17
- package/bpk-component-spinner/src/BpkSpinner.js +6 -19
- package/bpk-component-split-input/src/BpkInputField.d.ts +21 -0
- package/bpk-component-split-input/src/BpkInputField.js +12 -17
- package/bpk-component-split-input/src/BpkSplitInput.d.ts +44 -0
- package/bpk-component-split-input/src/BpkSplitInput.js +22 -33
- package/bpk-react-utils/src/nativeEventHandler.d.ts +1 -1
- package/bpk-react-utils/src/nativeEventHandler.js +7 -5
- package/bpk-stylesheets/test.css +164 -0
- package/package.json +3 -1
- package/bpk-component-nudger/src/BpkConfigurableNudger.d.ts +0 -26
- package/bpk-component-nudger/src/BpkConfigurableNudger.js +0 -96
|
@@ -16,30 +16,63 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import { useRef } from 'react';
|
|
20
|
+
import { BpkButtonV2, BUTTON_TYPES } from "../../bpk-component-button";
|
|
21
|
+
import { withButtonAlignment } from "../../bpk-component-icon";
|
|
22
|
+
import MinusIcon from "../../bpk-component-icon/sm/minus";
|
|
23
|
+
import PlusIcon from "../../bpk-component-icon/sm/plus";
|
|
19
24
|
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
20
25
|
import BpkLabel from "../../bpk-component-label";
|
|
21
26
|
import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
|
|
22
|
-
import { cssModules } from "../../bpk-react-utils";
|
|
23
|
-
import BpkConfigurableNudger from "./BpkConfigurableNudger";
|
|
27
|
+
import { cssModules, setNativeValue } from "../../bpk-react-utils";
|
|
24
28
|
import STYLES from "./BpkNudger.module.css";
|
|
25
29
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
30
|
const getClassName = cssModules(STYLES);
|
|
27
31
|
const compareValues = (a, b) => a - b;
|
|
28
|
-
const incrementValue = currentValue => currentValue + 1;
|
|
29
|
-
const decrementValue = currentValue => currentValue - 1;
|
|
30
|
-
const formatValue = currentValue => currentValue.toString();
|
|
31
32
|
const BpkNudger = ({
|
|
32
33
|
buttonType = 'secondary',
|
|
33
34
|
className = null,
|
|
35
|
+
decreaseButtonLabel,
|
|
34
36
|
icon,
|
|
35
37
|
id,
|
|
38
|
+
increaseButtonLabel,
|
|
39
|
+
inputClassName,
|
|
40
|
+
max,
|
|
41
|
+
min,
|
|
42
|
+
name,
|
|
43
|
+
onValueChange,
|
|
44
|
+
step = 1,
|
|
36
45
|
subtitle,
|
|
37
46
|
title,
|
|
47
|
+
value,
|
|
38
48
|
...rest
|
|
39
49
|
}) => {
|
|
40
|
-
|
|
50
|
+
// Ensure that the minimum value is 0 or greater it's not designed to handle negative values.
|
|
51
|
+
const minimum = min < 0 ? 0 : min;
|
|
52
|
+
const containerClassNames = getClassName(title && 'bpk-nudger__container');
|
|
53
|
+
const inputClassNames = getClassName('bpk-nudger__input', 'bpk-nudger__input--numeric', inputClassName && inputClassName, buttonType === 'secondaryOnDark' && 'bpk-nudger__input--secondary-on-dark');
|
|
54
|
+
const nudgerClassNames = getClassName('bpk-nudger', className);
|
|
55
|
+
const maxButtonDisabled = compareValues(value, max) >= 0;
|
|
56
|
+
const minButtonDisabled = compareValues(value, minimum) <= 0;
|
|
57
|
+
const AlignedMinusIcon = withButtonAlignment(MinusIcon);
|
|
58
|
+
const AlignedPlusIcon = withButtonAlignment(PlusIcon);
|
|
59
|
+
const inputRef = useRef(null);
|
|
60
|
+
const incrementValue = currentValue => currentValue + step;
|
|
61
|
+
const decrementValue = currentValue => currentValue - step;
|
|
62
|
+
const valueLimitter = element => {
|
|
63
|
+
if (element.valueAsNumber < minimum) {
|
|
64
|
+
onValueChange(minimum);
|
|
65
|
+
setNativeValue(element, minimum, false);
|
|
66
|
+
} else if (element.valueAsNumber > max) {
|
|
67
|
+
onValueChange(max);
|
|
68
|
+
setNativeValue(element, max, false);
|
|
69
|
+
}
|
|
70
|
+
if (element.valueAsNumber >= minimum && element.valueAsNumber <= max) {
|
|
71
|
+
onValueChange(element.valueAsNumber);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
41
74
|
return /*#__PURE__*/_jsxs("div", {
|
|
42
|
-
className:
|
|
75
|
+
className: containerClassNames,
|
|
43
76
|
children: [title && /*#__PURE__*/_jsxs("div", {
|
|
44
77
|
className: getClassName('bpk-nudger__label'),
|
|
45
78
|
children: [/*#__PURE__*/_jsx(BpkLabel, {
|
|
@@ -60,19 +93,68 @@ const BpkNudger = ({
|
|
|
60
93
|
})
|
|
61
94
|
})]
|
|
62
95
|
})]
|
|
63
|
-
}), /*#__PURE__*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
96
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
97
|
+
className: nudgerClassNames,
|
|
98
|
+
children: [/*#__PURE__*/_jsx(BpkButtonV2, {
|
|
99
|
+
type: BUTTON_TYPES[buttonType],
|
|
100
|
+
iconOnly: true,
|
|
101
|
+
onClick: () => {
|
|
102
|
+
if (Number.isNaN(value)) {
|
|
103
|
+
onValueChange(minimum);
|
|
104
|
+
inputRef.current && setNativeValue(inputRef.current, minimum);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const newValue = decrementValue(value);
|
|
108
|
+
onValueChange(newValue);
|
|
109
|
+
// We want to maintain native input events across our form components. Along with react updating
|
|
110
|
+
// the value attribute we can set it via native handlers and emit a "change" event.
|
|
111
|
+
inputRef.current && setNativeValue(inputRef.current, newValue);
|
|
112
|
+
},
|
|
113
|
+
disabled: minButtonDisabled,
|
|
114
|
+
title: decreaseButtonLabel,
|
|
115
|
+
"aria-controls": id,
|
|
116
|
+
children: /*#__PURE__*/_jsx(AlignedMinusIcon, {})
|
|
117
|
+
}), /*#__PURE__*/_jsx("input", {
|
|
118
|
+
type: "number",
|
|
119
|
+
"aria-live": "polite",
|
|
120
|
+
defaultValue: value,
|
|
121
|
+
id: id,
|
|
122
|
+
ref: inputRef,
|
|
123
|
+
name: name || id,
|
|
124
|
+
step: step,
|
|
125
|
+
onInput: event => {
|
|
126
|
+
const inputElement = event.target;
|
|
127
|
+
if (!inputElement.validity.valid &&
|
|
128
|
+
// allow the removal of a value
|
|
129
|
+
Number.isNaN(inputElement.valueAsNumber)) {
|
|
130
|
+
// set prev value if entry invalid
|
|
131
|
+
onValueChange(value);
|
|
132
|
+
setNativeValue(inputElement, value, false);
|
|
133
|
+
}
|
|
134
|
+
valueLimitter(inputElement);
|
|
135
|
+
},
|
|
136
|
+
className: inputClassNames,
|
|
137
|
+
...rest
|
|
138
|
+
}), /*#__PURE__*/_jsx(BpkButtonV2, {
|
|
139
|
+
type: BUTTON_TYPES[buttonType],
|
|
140
|
+
iconOnly: true,
|
|
141
|
+
onClick: () => {
|
|
142
|
+
if (Number.isNaN(value)) {
|
|
143
|
+
onValueChange(max);
|
|
144
|
+
inputRef.current && setNativeValue(inputRef.current, max);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const newValue = incrementValue(value);
|
|
148
|
+
onValueChange(newValue);
|
|
149
|
+
// We want to maintain native input events across our form components. Along with react updating
|
|
150
|
+
// the value attribute we can set it via native handlers and emit a "change" event.
|
|
151
|
+
inputRef.current && setNativeValue(inputRef.current, newValue);
|
|
152
|
+
},
|
|
153
|
+
disabled: maxButtonDisabled,
|
|
154
|
+
title: increaseButtonLabel,
|
|
155
|
+
"aria-controls": id,
|
|
156
|
+
children: /*#__PURE__*/_jsx(AlignedPlusIcon, {})
|
|
157
|
+
})]
|
|
76
158
|
})]
|
|
77
159
|
});
|
|
78
160
|
};
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
html[dir=rtl] .bpk-nudger{display:flex
|
|
18
|
+
html[dir=rtl] .bpk-nudger{display:flex}.bpk-nudger__input{display:inline-block;padding:.5rem 0;border:none;color:#161616;text-align:center;vertical-align:middle;margin:0;font-size:1rem;line-height:1.25rem;font-weight:700}.bpk-nudger__input::-webkit-outer-spin-button,.bpk-nudger__input::-webkit-inner-spin-button{margin:0;appearance:none}.bpk-nudger__input[type=number]{appearance:textfield}.bpk-nudger__input--secondary-on-dark{background-color:rgba(0,0,0,0);color:#fff}.bpk-nudger__input--numeric{width:2.5rem}.bpk-nudger__container{display:flex;justify-content:space-between;align-items:center}.bpk-nudger__label{display:flex;gap:.5rem}.bpk-nudger__label--title-subtitle{display:inline-flex;flex-direction:column;justify-content:space-between}.bpk-nudger__label--subtitle{color:#626971}
|
|
@@ -5,11 +5,12 @@ export declare const BUTTON_TYPES: {
|
|
|
5
5
|
};
|
|
6
6
|
export type CommonProps = {
|
|
7
7
|
id: string;
|
|
8
|
-
min:
|
|
9
|
-
max:
|
|
10
|
-
value:
|
|
11
|
-
|
|
12
|
-
name?: string |
|
|
8
|
+
min: number;
|
|
9
|
+
max: number;
|
|
10
|
+
value: number;
|
|
11
|
+
onValueChange: (arg0: number) => void;
|
|
12
|
+
name?: string | undefined;
|
|
13
|
+
step?: number;
|
|
13
14
|
className?: string | null;
|
|
14
15
|
/**
|
|
15
16
|
* This is the label that will be read out when screen reader users tab to the increase button. Make sure you use a descriptive label.
|
|
@@ -18,6 +19,7 @@ export type CommonProps = {
|
|
|
18
19
|
* Function that handle the incrementing of the current selected value.
|
|
19
20
|
*/
|
|
20
21
|
increaseButtonLabel: string;
|
|
22
|
+
inputClassName?: string | undefined;
|
|
21
23
|
/**
|
|
22
24
|
* This is the label that will be read out when screen reader users tab to the decrease button. Make sure you use a descriptive label
|
|
23
25
|
*/
|
|
@@ -8,7 +8,10 @@ export type Props = {
|
|
|
8
8
|
value: number[] | number;
|
|
9
9
|
ariaLabel: string[];
|
|
10
10
|
ariaValuetext?: string[];
|
|
11
|
+
inputProps?: [{
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}];
|
|
11
14
|
[rest: string]: any;
|
|
12
15
|
};
|
|
13
|
-
declare const BpkSlider: ({ ariaLabel, ariaValuetext, max, min, minDistance, onAfterChange, onChange, step, value, ...rest }: Props) => JSX.Element;
|
|
16
|
+
declare const BpkSlider: ({ ariaLabel, ariaValuetext, inputProps, max, min, minDistance, onAfterChange, onChange, step, value, ...rest }: Props) => JSX.Element;
|
|
14
17
|
export default BpkSlider;
|
|
@@ -15,15 +15,18 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
import { forwardRef, useRef, useEffect } from 'react';
|
|
19
|
+
import { useComposedRefs } from '@radix-ui/react-compose-refs';
|
|
19
20
|
import * as Slider from '@radix-ui/react-slider';
|
|
20
|
-
import {
|
|
21
|
+
import { usePrevious } from '@radix-ui/react-use-previous';
|
|
22
|
+
import { cssModules, isRTL, setNativeValue } from "../../bpk-react-utils";
|
|
21
23
|
import STYLES from "./BpkSlider.module.css";
|
|
22
24
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
25
|
const getClassName = cssModules(STYLES);
|
|
24
26
|
const BpkSlider = ({
|
|
25
27
|
ariaLabel,
|
|
26
28
|
ariaValuetext,
|
|
29
|
+
inputProps,
|
|
27
30
|
max,
|
|
28
31
|
min,
|
|
29
32
|
minDistance,
|
|
@@ -67,8 +70,53 @@ const BpkSlider = ({
|
|
|
67
70
|
"aria-label": ariaLabel[index],
|
|
68
71
|
"aria-valuetext": ariaValuetext ? ariaValuetext[index] : val.toString(),
|
|
69
72
|
className: getClassName('bpk-slider__thumb'),
|
|
70
|
-
"aria-valuenow": currentValue[index]
|
|
73
|
+
"aria-valuenow": currentValue[index],
|
|
74
|
+
asChild: true,
|
|
75
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
76
|
+
children: /*#__PURE__*/_jsx(BubbleInput, {
|
|
77
|
+
value: currentValue[index],
|
|
78
|
+
...(inputProps && inputProps[index])
|
|
79
|
+
})
|
|
80
|
+
})
|
|
71
81
|
}, ariaLabel[index]))]
|
|
72
82
|
});
|
|
73
83
|
};
|
|
84
|
+
|
|
85
|
+
// Work around until radix-ui/react-slider is updated to accept an inputRef prop https://github.com/radix-ui/primitives/pull/3033
|
|
86
|
+
const BubbleInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
87
|
+
const {
|
|
88
|
+
value,
|
|
89
|
+
...inputProps
|
|
90
|
+
} = props;
|
|
91
|
+
const ref = useRef();
|
|
92
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
93
|
+
const prevValue = usePrevious(value);
|
|
94
|
+
|
|
95
|
+
// Bubble value change to parents (e.g form change event)
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
const input = ref.current;
|
|
98
|
+
if (prevValue !== value) {
|
|
99
|
+
setNativeValue(input, `${value}`);
|
|
100
|
+
}
|
|
101
|
+
}, [prevValue, value]);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* We purposefully do not use `type="hidden"` here otherwise forms that
|
|
105
|
+
* wrap it will not be able to access its value via the FormData API.
|
|
106
|
+
*
|
|
107
|
+
* We purposefully do not add the `value` attribute here to allow the value
|
|
108
|
+
* to be set programatically and bubble to any parent form `onChange` event.
|
|
109
|
+
* Adding the `value` will cause React to consider the programatic
|
|
110
|
+
* dispatch a duplicate and it will get swallowed.
|
|
111
|
+
*/
|
|
112
|
+
return /*#__PURE__*/_jsx("input", {
|
|
113
|
+
style: {
|
|
114
|
+
display: 'none'
|
|
115
|
+
},
|
|
116
|
+
...inputProps,
|
|
117
|
+
ref: composedRefs,
|
|
118
|
+
type: "number",
|
|
119
|
+
defaultValue: value
|
|
120
|
+
});
|
|
121
|
+
});
|
|
74
122
|
export default BpkSlider;
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import type { SpinnerTypes } from './spinnerTypes';
|
|
3
2
|
type Props = {
|
|
4
|
-
type
|
|
5
|
-
className?: string;
|
|
6
|
-
|
|
7
|
-
declare const BpkExtraLargeSpinner: {
|
|
8
|
-
(props: Props): JSX.Element;
|
|
9
|
-
propTypes: {
|
|
10
|
-
type: PropTypes.Requireable<string>;
|
|
11
|
-
className: PropTypes.Requireable<string>;
|
|
12
|
-
};
|
|
13
|
-
defaultProps: {
|
|
14
|
-
type: "dark";
|
|
15
|
-
className: null;
|
|
16
|
-
};
|
|
3
|
+
type?: SpinnerTypes;
|
|
4
|
+
className?: string | null;
|
|
5
|
+
[rest: string]: any;
|
|
17
6
|
};
|
|
7
|
+
declare const BpkExtraLargeSpinner: ({ className, type, ...rest }: Props) => JSX.Element;
|
|
18
8
|
export default BpkExtraLargeSpinner;
|
|
@@ -16,8 +16,6 @@ import React from "react";
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
import PropTypes from 'prop-types';
|
|
21
19
|
var XlSpinner = function XlSpinner(props) {
|
|
22
20
|
return /*#__PURE__*/_jsxs("svg", {
|
|
23
21
|
...props,
|
|
@@ -81,12 +79,11 @@ import SPINNER_TYPES from "./spinnerTypes";
|
|
|
81
79
|
import STYLES from "./BpkSpinner.module.css";
|
|
82
80
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
83
81
|
const getClassName = cssModules(STYLES);
|
|
84
|
-
const BpkExtraLargeSpinner =
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} = props;
|
|
82
|
+
const BpkExtraLargeSpinner = ({
|
|
83
|
+
className = null,
|
|
84
|
+
type = SPINNER_TYPES.dark,
|
|
85
|
+
...rest
|
|
86
|
+
}) => {
|
|
90
87
|
const classNames = getClassName('bpk-spinner', 'bpk-spinner--extra-large', `bpk-spinner--${type}`, className);
|
|
91
88
|
return /*#__PURE__*/_jsx("span", {
|
|
92
89
|
className: classNames,
|
|
@@ -95,12 +92,4 @@ const BpkExtraLargeSpinner = props => {
|
|
|
95
92
|
})
|
|
96
93
|
});
|
|
97
94
|
};
|
|
98
|
-
BpkExtraLargeSpinner.propTypes = {
|
|
99
|
-
type: PropTypes.oneOf(Object.keys(SPINNER_TYPES)),
|
|
100
|
-
className: PropTypes.string
|
|
101
|
-
};
|
|
102
|
-
BpkExtraLargeSpinner.defaultProps = {
|
|
103
|
-
type: SPINNER_TYPES.dark,
|
|
104
|
-
className: null
|
|
105
|
-
};
|
|
106
95
|
export default BpkExtraLargeSpinner;
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import type { SpinnerTypes } from './spinnerTypes';
|
|
3
2
|
type Props = {
|
|
4
|
-
type
|
|
5
|
-
className?: string;
|
|
6
|
-
alignToButton
|
|
7
|
-
|
|
8
|
-
declare const BpkLargeSpinner: {
|
|
9
|
-
(props: Props): JSX.Element;
|
|
10
|
-
propTypes: {
|
|
11
|
-
type: PropTypes.Requireable<string>;
|
|
12
|
-
className: PropTypes.Requireable<string>;
|
|
13
|
-
alignToButton: PropTypes.Requireable<boolean>;
|
|
14
|
-
};
|
|
15
|
-
defaultProps: {
|
|
16
|
-
type: "dark";
|
|
17
|
-
className: null;
|
|
18
|
-
alignToButton: boolean;
|
|
19
|
-
};
|
|
3
|
+
type?: SpinnerTypes;
|
|
4
|
+
className?: string | null;
|
|
5
|
+
alignToButton?: boolean;
|
|
6
|
+
[rest: string]: any;
|
|
20
7
|
};
|
|
8
|
+
declare const BpkLargeSpinner: ({ alignToButton, className, type, ...rest }: Props) => JSX.Element;
|
|
21
9
|
export default BpkLargeSpinner;
|
|
@@ -16,8 +16,6 @@ import React from "react";
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
import PropTypes from 'prop-types';
|
|
21
19
|
var LgSpinner = function LgSpinner(props) {
|
|
22
20
|
return /*#__PURE__*/_jsxs("svg", {
|
|
23
21
|
...props,
|
|
@@ -81,13 +79,12 @@ import SPINNER_TYPES from "./spinnerTypes";
|
|
|
81
79
|
import STYLES from "./BpkSpinner.module.css";
|
|
82
80
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
83
81
|
const getClassName = cssModules(STYLES);
|
|
84
|
-
const BpkLargeSpinner =
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
} = props;
|
|
82
|
+
const BpkLargeSpinner = ({
|
|
83
|
+
alignToButton = false,
|
|
84
|
+
className = null,
|
|
85
|
+
type = SPINNER_TYPES.dark,
|
|
86
|
+
...rest
|
|
87
|
+
}) => {
|
|
91
88
|
const classNames = getClassName('bpk-spinner', 'bpk-spinner--large', `bpk-spinner--${type}`, alignToButton && 'bpk-spinner--align-to-large-button', className);
|
|
92
89
|
return /*#__PURE__*/_jsx("span", {
|
|
93
90
|
className: classNames,
|
|
@@ -96,14 +93,4 @@ const BpkLargeSpinner = props => {
|
|
|
96
93
|
})
|
|
97
94
|
});
|
|
98
95
|
};
|
|
99
|
-
BpkLargeSpinner.propTypes = {
|
|
100
|
-
type: PropTypes.oneOf(Object.keys(SPINNER_TYPES)),
|
|
101
|
-
className: PropTypes.string,
|
|
102
|
-
alignToButton: PropTypes.bool
|
|
103
|
-
};
|
|
104
|
-
BpkLargeSpinner.defaultProps = {
|
|
105
|
-
type: SPINNER_TYPES.dark,
|
|
106
|
-
className: null,
|
|
107
|
-
alignToButton: false
|
|
108
|
-
};
|
|
109
96
|
export default BpkLargeSpinner;
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import type { SpinnerTypes } from './spinnerTypes';
|
|
3
2
|
type Props = {
|
|
4
|
-
type
|
|
5
|
-
className?: string;
|
|
6
|
-
alignToButton
|
|
7
|
-
|
|
8
|
-
declare const BpkSpinner: {
|
|
9
|
-
(props: Props): JSX.Element;
|
|
10
|
-
propTypes: {
|
|
11
|
-
type: PropTypes.Requireable<string>;
|
|
12
|
-
className: PropTypes.Requireable<string>;
|
|
13
|
-
alignToButton: PropTypes.Requireable<boolean>;
|
|
14
|
-
};
|
|
15
|
-
defaultProps: {
|
|
16
|
-
type: "dark";
|
|
17
|
-
className: null;
|
|
18
|
-
alignToButton: boolean;
|
|
19
|
-
};
|
|
3
|
+
type?: SpinnerTypes;
|
|
4
|
+
className?: string | null;
|
|
5
|
+
alignToButton?: boolean;
|
|
6
|
+
[rest: string]: any;
|
|
20
7
|
};
|
|
8
|
+
declare const BpkSpinner: ({ alignToButton, className, type, ...rest }: Props) => JSX.Element;
|
|
21
9
|
export default BpkSpinner;
|
|
@@ -16,8 +16,6 @@ import React from "react";
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
import PropTypes from 'prop-types';
|
|
21
19
|
var SmSpinner = function SmSpinner(props) {
|
|
22
20
|
return /*#__PURE__*/_jsxs("svg", {
|
|
23
21
|
...props,
|
|
@@ -68,13 +66,12 @@ import SPINNER_TYPES from "./spinnerTypes";
|
|
|
68
66
|
import STYLES from "./BpkSpinner.module.css";
|
|
69
67
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
70
68
|
const getClassName = cssModules(STYLES);
|
|
71
|
-
const BpkSpinner =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} = props;
|
|
69
|
+
const BpkSpinner = ({
|
|
70
|
+
alignToButton = false,
|
|
71
|
+
className = null,
|
|
72
|
+
type = SPINNER_TYPES.dark,
|
|
73
|
+
...rest
|
|
74
|
+
}) => {
|
|
78
75
|
const classNames = getClassName('bpk-spinner', `bpk-spinner--${type}`, alignToButton && 'bpk-spinner--align-to-button', className);
|
|
79
76
|
return /*#__PURE__*/_jsx("span", {
|
|
80
77
|
className: classNames,
|
|
@@ -83,14 +80,4 @@ const BpkSpinner = props => {
|
|
|
83
80
|
})
|
|
84
81
|
});
|
|
85
82
|
};
|
|
86
|
-
BpkSpinner.propTypes = {
|
|
87
|
-
type: PropTypes.oneOf(Object.keys(SPINNER_TYPES)),
|
|
88
|
-
className: PropTypes.string,
|
|
89
|
-
alignToButton: PropTypes.bool
|
|
90
|
-
};
|
|
91
|
-
BpkSpinner.defaultProps = {
|
|
92
|
-
type: SPINNER_TYPES.dark,
|
|
93
|
-
className: null,
|
|
94
|
-
alignToButton: false
|
|
95
|
-
};
|
|
96
83
|
export default BpkSpinner;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PureComponent } from 'react';
|
|
2
|
+
export type Props = DefaultProps;
|
|
3
|
+
type DefaultProps = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
value: string | number;
|
|
7
|
+
focus: boolean;
|
|
8
|
+
index: number;
|
|
9
|
+
name: string;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
declare class BpkInputField extends PureComponent<Props> {
|
|
13
|
+
static defaultProps: {
|
|
14
|
+
value: string;
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
17
|
+
componentDidUpdate(prevProps: Props): void;
|
|
18
|
+
private input;
|
|
19
|
+
render(): JSX.Element;
|
|
20
|
+
}
|
|
21
|
+
export default BpkInputField;
|
|
@@ -14,14 +14,19 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { PureComponent } from 'react';
|
|
19
20
|
import BpkInput from "../../bpk-component-input";
|
|
20
21
|
import { cssModules } from "../../bpk-react-utils";
|
|
21
22
|
import STYLES from "./BpkInputField.module.css";
|
|
22
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
24
|
const getClassName = cssModules(STYLES);
|
|
24
|
-
class BpkInputField extends
|
|
25
|
+
class BpkInputField extends PureComponent {
|
|
26
|
+
static defaultProps = {
|
|
27
|
+
value: '',
|
|
28
|
+
name: ''
|
|
29
|
+
};
|
|
25
30
|
componentDidUpdate(prevProps) {
|
|
26
31
|
const {
|
|
27
32
|
focus
|
|
@@ -31,6 +36,7 @@ class BpkInputField extends Component {
|
|
|
31
36
|
this.input.select();
|
|
32
37
|
}
|
|
33
38
|
}
|
|
39
|
+
input = null;
|
|
34
40
|
render() {
|
|
35
41
|
const {
|
|
36
42
|
focus,
|
|
@@ -46,27 +52,16 @@ class BpkInputField extends Component {
|
|
|
46
52
|
children: /*#__PURE__*/_jsx(BpkInput, {
|
|
47
53
|
id: id,
|
|
48
54
|
autoComplete: "off",
|
|
49
|
-
|
|
55
|
+
name: name,
|
|
56
|
+
maxLength: 1,
|
|
50
57
|
"aria-label": `${label} ${index}`,
|
|
51
58
|
inputRef: input => {
|
|
52
59
|
this.input = input;
|
|
53
60
|
},
|
|
54
|
-
value: value
|
|
55
|
-
name: name || '',
|
|
61
|
+
value: value,
|
|
56
62
|
...rest
|
|
57
63
|
})
|
|
58
64
|
}, index);
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
|
-
BpkInputField.propTypes = {
|
|
62
|
-
id: PropTypes.string.isRequired,
|
|
63
|
-
label: PropTypes.string.isRequired,
|
|
64
|
-
value: PropTypes.string,
|
|
65
|
-
focus: PropTypes.bool.isRequired,
|
|
66
|
-
index: PropTypes.number.isRequired,
|
|
67
|
-
name: PropTypes.string
|
|
68
|
-
};
|
|
69
|
-
BpkInputField.defaultProps = {
|
|
70
|
-
value: ''
|
|
71
|
-
};
|
|
72
67
|
export default BpkInputField;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import type { ChangeEvent, ClipboardEvent, FocusEvent, KeyboardEvent } from 'react';
|
|
3
|
+
import { INPUT_TYPES } from '../../bpk-component-input';
|
|
4
|
+
interface Props {
|
|
5
|
+
type?: string | number;
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
name: string;
|
|
9
|
+
inputLength?: number;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
onInputChange: (value: string | number) => void;
|
|
12
|
+
onSubmit: (value: string | number) => void;
|
|
13
|
+
large?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface State {
|
|
16
|
+
focusedInput: number;
|
|
17
|
+
inputValue: string[] | number[];
|
|
18
|
+
}
|
|
19
|
+
declare class BpkSplitInput extends Component<Props, State> {
|
|
20
|
+
static defaultProps: {
|
|
21
|
+
type: "number";
|
|
22
|
+
inputLength: number;
|
|
23
|
+
large: boolean;
|
|
24
|
+
placeholder: string;
|
|
25
|
+
};
|
|
26
|
+
constructor(props: Props);
|
|
27
|
+
onInputChange: (input: string[] | number[]) => void;
|
|
28
|
+
updateInputValue: (value: string | number) => void;
|
|
29
|
+
handleSubmit: () => void;
|
|
30
|
+
validateInput: (inputValue: string[] | number[]) => boolean;
|
|
31
|
+
isNumeric: () => boolean;
|
|
32
|
+
isInputValid: (value: string | number) => boolean;
|
|
33
|
+
focusInput: (inputIndex: number) => void;
|
|
34
|
+
focusNextInput: () => void;
|
|
35
|
+
focusPreviousInput: () => void;
|
|
36
|
+
handleOnPaste: (e: ClipboardEvent<HTMLInputElement>) => void;
|
|
37
|
+
handleOnKeyDown: (e: KeyboardEvent<HTMLInputElement>) => void;
|
|
38
|
+
handleOnChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
39
|
+
handleOnFocus: (e: FocusEvent<HTMLInputElement>, index: number) => void;
|
|
40
|
+
renderInputs: () => JSX.Element[];
|
|
41
|
+
render(): JSX.Element;
|
|
42
|
+
}
|
|
43
|
+
export default BpkSplitInput;
|
|
44
|
+
export { INPUT_TYPES };
|