@skyscanner/backpack-web 33.7.0 → 33.8.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.
@@ -0,0 +1,60 @@
1
+ import PropTypes from 'prop-types';
2
+ import type { ReactElement, ReactNode } from 'react';
3
+ export declare const ICON_POSITION: {
4
+ LEADING: string;
5
+ TRAILING: string;
6
+ };
7
+ type LoadingProps = {
8
+ featured?: boolean;
9
+ secondaryOnDark?: boolean;
10
+ primaryOnLight?: boolean;
11
+ primaryOnDark?: boolean;
12
+ children: ReactNode;
13
+ className?: string;
14
+ disabled?: boolean;
15
+ secondary?: boolean;
16
+ destructive?: boolean;
17
+ large?: boolean;
18
+ link?: boolean;
19
+ linkOnDark?: boolean;
20
+ loading: boolean;
21
+ iconOnly: boolean;
22
+ icon?: ReactElement<any>;
23
+ iconPosition: string;
24
+ iconDisabled?: ReactElement<any>;
25
+ iconLoading?: ReactElement<any>;
26
+ };
27
+ declare const BpkLoadingButton: {
28
+ (props: LoadingProps): JSX.Element;
29
+ propTypes: {
30
+ children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
31
+ className: PropTypes.Requireable<string>;
32
+ disabled: PropTypes.Requireable<boolean>;
33
+ secondary: PropTypes.Requireable<boolean>;
34
+ destructive: PropTypes.Requireable<boolean>;
35
+ link: PropTypes.Requireable<boolean>;
36
+ linkOnDark: PropTypes.Requireable<boolean>;
37
+ loading: PropTypes.Requireable<boolean>;
38
+ iconOnly: PropTypes.Requireable<boolean>;
39
+ icon: PropTypes.Requireable<PropTypes.ReactElementLike>;
40
+ iconPosition: PropTypes.Requireable<string>;
41
+ iconDisabled: PropTypes.Requireable<PropTypes.ReactElementLike>;
42
+ iconLoading: PropTypes.Requireable<PropTypes.ReactElementLike>;
43
+ };
44
+ defaultProps: {
45
+ className: null;
46
+ disabled: boolean;
47
+ secondary: boolean;
48
+ destructive: boolean;
49
+ large: boolean;
50
+ link: boolean;
51
+ linkOnDark: boolean;
52
+ loading: boolean;
53
+ iconOnly: boolean;
54
+ icon: null;
55
+ iconPosition: string;
56
+ iconDisabled: null;
57
+ iconLoading: null;
58
+ };
59
+ };
60
+ export default BpkLoadingButton;
@@ -14,8 +14,10 @@
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
- */import PropTypes from 'prop-types';
18
- import BpkButton from "../../bpk-component-button";
17
+ */
18
+
19
+ import PropTypes from 'prop-types';
20
+ import { BUTTON_TYPES, BpkButtonV2, SIZE_TYPES } from "../../bpk-component-button";
19
21
  import { withButtonAlignment, withLargeButtonAlignment, withRtlSupport } from "../../bpk-component-icon";
20
22
  import ArrowIconLg from "../../bpk-component-icon/lg/long-arrow-right";
21
23
  import ArrowIconSm from "../../bpk-component-icon/sm/long-arrow-right";
@@ -58,7 +60,6 @@ const getLoadingIcon = props => {
58
60
  const BpkLoadingButton = props => {
59
61
  const {
60
62
  children,
61
- className,
62
63
  disabled,
63
64
  icon,
64
65
  iconDisabled,
@@ -66,8 +67,6 @@ const BpkLoadingButton = props => {
66
67
  iconOnly,
67
68
  iconPosition,
68
69
  large,
69
- link,
70
- linkOnDark,
71
70
  loading,
72
71
  ...rest
73
72
  } = props;
@@ -76,28 +75,49 @@ const BpkLoadingButton = props => {
76
75
  const buttonIcon = getPropsIcon(props) || getEnabledIcon(large);
77
76
  const [child0, child1, child2] = iconPosition === ICON_POSITION.LEADING ? [buttonIcon, spacer, children] : [children, spacer, buttonIcon];
78
77
  const loadingIcon = getLoadingIcon(props);
79
- const classNames = getClassName(loading && 'bpk-loading-button', loading && (link || linkOnDark) && 'bpk-loading-button--link', className);
80
- const iconClassNames = getClassName('bpk-loading-button__icon', large && 'bpk-loading-button__icon--large', iconOnly && (large ? 'bpk-loading-button__icon--large-icon-only' : 'bpk-loading-button__icon--icon-only'), (link || linkOnDark) && 'bpk-loading-button__icon--link');
81
- return (
82
- /*#__PURE__*/
83
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
84
- _jsxs(BpkButton, {
85
- iconOnly: iconOnly,
86
- disabled: showBtnDisabled,
87
- large: large
88
- // TODO: className to be removed
89
- // eslint-disable-next-line @skyscanner/rules/forbid-component-props
90
- ,
91
- className: classNames,
92
- link: link,
93
- linkOnDark: linkOnDark,
94
- ...rest,
78
+ const iconClassNames = getClassName('bpk-loading-button__icon');
79
+ let type = BUTTON_TYPES.primary;
80
+ if (props.link) {
81
+ type = BUTTON_TYPES.link;
82
+ }
83
+ if (props.linkOnDark) {
84
+ type = BUTTON_TYPES.linkOnDark;
85
+ }
86
+ if (props.featured) {
87
+ type = BUTTON_TYPES.featured;
88
+ }
89
+ if (props.destructive) {
90
+ type = BUTTON_TYPES.destructive;
91
+ }
92
+ if (props.secondaryOnDark) {
93
+ type = BUTTON_TYPES.secondaryOnDark;
94
+ }
95
+ if (props.secondary) {
96
+ type = BUTTON_TYPES.secondary;
97
+ }
98
+ if (props.primaryOnLight) {
99
+ type = BUTTON_TYPES.primaryOnLight;
100
+ }
101
+ if (props.primaryOnDark) {
102
+ type = BUTTON_TYPES.primaryOnDark;
103
+ }
104
+ return /*#__PURE__*/_jsx(BpkButtonV2, {
105
+ iconOnly: iconOnly,
106
+ disabled: showBtnDisabled,
107
+ size: large ? SIZE_TYPES.large : SIZE_TYPES.small,
108
+ type: type,
109
+ ...rest,
110
+ children: /*#__PURE__*/_jsxs("div", {
111
+ className: getClassName('bpk-loading-button__container'),
95
112
  children: [loading && /*#__PURE__*/_jsx("span", {
96
113
  className: iconClassNames,
97
114
  children: loadingIcon
98
- }), child0, child1, child2]
115
+ }), /*#__PURE__*/_jsxs("div", {
116
+ className: getClassName(loading ? "bpk-loading-button--hidden" : "bpk-loading-button--visible"),
117
+ children: [child0, child1, child2]
118
+ })]
99
119
  })
100
- );
120
+ });
101
121
  };
102
122
  BpkLoadingButton.propTypes = {
103
123
  children: PropTypes.node.isRequired,
@@ -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
- .bpk-loading-button{position:relative;overflow:hidden}.bpk-loading-button--link{visibility:hidden}.bpk-loading-button__icon{position:absolute;display:inline-flex;visibility:visible;z-index:1;width:calc(100% - 2rem);height:calc(100% - 0.75rem);justify-content:center;align-items:center;background-color:inherit}.bpk-loading-button__icon--large{height:calc(100% - 1.5rem)}.bpk-loading-button__icon--icon-only{width:calc(100% - 1.25rem)}.bpk-loading-button__icon--large-icon-only{width:calc(100% - 1.5rem)}.bpk-loading-button__icon--link{width:100%;background:unset}
18
+ .bpk-loading-button__container{display:inline-flex;justify-content:center;align-items:center}.bpk-loading-button__icon{position:absolute;display:inline-flex}.bpk-loading-button--hidden{visibility:hidden}.bpk-loading-button--visible{visibility:visible}
@@ -190,7 +190,7 @@
190
190
  padding: 0;
191
191
  border: 0;
192
192
  background-color: transparent;
193
- color: tokens.$bpk-text-secondary-day;
193
+ color: $bpk-text-secondary-day;
194
194
  cursor: pointer;
195
195
  appearance: none; // hidden by default
196
196
 
@@ -200,11 +200,11 @@
200
200
  }
201
201
 
202
202
  @include utils.bpk-hover {
203
- color: tokens.$bpk-text-primary-day;
203
+ color: $bpk-text-primary-day;
204
204
  }
205
205
 
206
206
  &:active {
207
- color: tokens.$bpk-text-primary-day;
207
+ color: $bpk-text-primary-day;
208
208
  }
209
209
 
210
210
  &--large {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "33.7.0",
3
+ "version": "33.8.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",