@khanacademy/wonder-blocks-icon-button 8.0.0 → 9.0.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/CHANGELOG.md +21 -0
- package/dist/components/icon-button-core.d.ts +1 -1
- package/dist/components/icon-button.d.ts +1 -1
- package/dist/es/index.js +29 -32
- package/dist/index.js +30 -33
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-icon-button
|
|
2
2
|
|
|
3
|
+
## 9.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 38c926c: Upgrade WB to using react-router-dom-v5-compat.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [38c926c]
|
|
12
|
+
- @khanacademy/wonder-blocks-clickable@7.0.0
|
|
13
|
+
- @khanacademy/wonder-blocks-core@12.2.1
|
|
14
|
+
|
|
15
|
+
## 8.0.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [24bf12f]
|
|
20
|
+
- @khanacademy/wonder-blocks-tokens@6.0.0
|
|
21
|
+
- @khanacademy/wonder-blocks-clickable@6.1.6
|
|
22
|
+
- @khanacademy/wonder-blocks-styles@0.2.2
|
|
23
|
+
|
|
3
24
|
## 8.0.0
|
|
4
25
|
|
|
5
26
|
### Major Changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { PhosphorIconAsset } from "@khanacademy/wonder-blocks-icon";
|
|
3
3
|
import type { AriaProps, StyleType } from "@khanacademy/wonder-blocks-core";
|
|
4
|
-
import { Link } from "react-router-dom";
|
|
4
|
+
import { Link } from "react-router-dom-v5-compat";
|
|
5
5
|
export type IconButtonSize = "xsmall" | "small" | "medium" | "large";
|
|
6
6
|
export type IconButtonActionType = "progressive" | "destructive" | "neutral";
|
|
7
7
|
export type SharedProps = Partial<Omit<AriaProps, "aria-disabled">> & {
|
package/dist/es/index.js
CHANGED
|
@@ -2,8 +2,7 @@ import _extends from '@babel/runtime/helpers/extends';
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutPropertiesLoose';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { StyleSheet } from 'aphrodite';
|
|
5
|
-
import { Link } from 'react-router-dom';
|
|
6
|
-
import { __RouterContext } from 'react-router';
|
|
5
|
+
import { Link, useInRouterContext } from 'react-router-dom-v5-compat';
|
|
7
6
|
import { addStyle } from '@khanacademy/wonder-blocks-core';
|
|
8
7
|
import { isClientSideUrl } from '@khanacademy/wonder-blocks-clickable';
|
|
9
8
|
import { PhosphorIcon } from '@khanacademy/wonder-blocks-icon';
|
|
@@ -117,36 +116,34 @@ const IconButtonCore = React.forwardRef(function IconButtonCore(props, ref) {
|
|
|
117
116
|
theme,
|
|
118
117
|
themeName
|
|
119
118
|
} = useScopedTheme(IconButtonThemeContext);
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
};
|
|
149
|
-
return React.createElement(__RouterContext.Consumer, null, router => renderInner(router));
|
|
119
|
+
const inRouterContext = useInRouterContext();
|
|
120
|
+
const buttonStyles = _generateStyles(actionType, !!disabled, kind, size, theme, themeName);
|
|
121
|
+
const defaultStyle = [sharedStyles.shared, buttonStyles.default, disabled && buttonStyles.disabled];
|
|
122
|
+
const child = React.createElement(IconChooser, {
|
|
123
|
+
size: size,
|
|
124
|
+
icon: icon
|
|
125
|
+
});
|
|
126
|
+
const commonProps = _extends({
|
|
127
|
+
"data-testid": testId,
|
|
128
|
+
style: [defaultStyle, style]
|
|
129
|
+
}, restProps);
|
|
130
|
+
if (href && !disabled) {
|
|
131
|
+
return inRouterContext && !skipClientNav && isClientSideUrl(href) ? React.createElement(StyledLink, _extends({}, commonProps, {
|
|
132
|
+
to: href,
|
|
133
|
+
ref: ref
|
|
134
|
+
}), child) : React.createElement(StyledA, _extends({}, commonProps, {
|
|
135
|
+
href: href,
|
|
136
|
+
ref: ref
|
|
137
|
+
}), child);
|
|
138
|
+
} else {
|
|
139
|
+
return React.createElement(StyledButton, _extends({
|
|
140
|
+
type: type
|
|
141
|
+
}, commonProps, {
|
|
142
|
+
onClick: disabled ? undefined : restProps.onClick,
|
|
143
|
+
"aria-disabled": disabled,
|
|
144
|
+
ref: ref
|
|
145
|
+
}), child);
|
|
146
|
+
}
|
|
150
147
|
});
|
|
151
148
|
const sharedStyles = StyleSheet.create({
|
|
152
149
|
shared: {
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,7 @@ var _extends = require('@babel/runtime/helpers/extends');
|
|
|
4
4
|
var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var aphrodite = require('aphrodite');
|
|
7
|
-
var
|
|
8
|
-
var reactRouter = require('react-router');
|
|
7
|
+
var reactRouterDomV5Compat = require('react-router-dom-v5-compat');
|
|
9
8
|
var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
|
|
10
9
|
var wonderBlocksClickable = require('@khanacademy/wonder-blocks-clickable');
|
|
11
10
|
var wonderBlocksIcon = require('@khanacademy/wonder-blocks-icon');
|
|
@@ -124,7 +123,7 @@ function IconChooser({
|
|
|
124
123
|
}
|
|
125
124
|
const StyledA = wonderBlocksCore.addStyle("a");
|
|
126
125
|
const StyledButton = wonderBlocksCore.addStyle("button");
|
|
127
|
-
const StyledLink = wonderBlocksCore.addStyle(
|
|
126
|
+
const StyledLink = wonderBlocksCore.addStyle(reactRouterDomV5Compat.Link);
|
|
128
127
|
const IconButtonCore = React__namespace.forwardRef(function IconButtonCore(props, ref) {
|
|
129
128
|
const {
|
|
130
129
|
actionType,
|
|
@@ -143,36 +142,34 @@ const IconButtonCore = React__namespace.forwardRef(function IconButtonCore(props
|
|
|
143
142
|
theme,
|
|
144
143
|
themeName
|
|
145
144
|
} = wonderBlocksTheming.useScopedTheme(IconButtonThemeContext);
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
};
|
|
175
|
-
return React__namespace.createElement(reactRouter.__RouterContext.Consumer, null, router => renderInner(router));
|
|
145
|
+
const inRouterContext = reactRouterDomV5Compat.useInRouterContext();
|
|
146
|
+
const buttonStyles = _generateStyles(actionType, !!disabled, kind, size, theme, themeName);
|
|
147
|
+
const defaultStyle = [sharedStyles.shared, buttonStyles.default, disabled && buttonStyles.disabled];
|
|
148
|
+
const child = React__namespace.createElement(IconChooser, {
|
|
149
|
+
size: size,
|
|
150
|
+
icon: icon
|
|
151
|
+
});
|
|
152
|
+
const commonProps = _extends__default["default"]({
|
|
153
|
+
"data-testid": testId,
|
|
154
|
+
style: [defaultStyle, style]
|
|
155
|
+
}, restProps);
|
|
156
|
+
if (href && !disabled) {
|
|
157
|
+
return inRouterContext && !skipClientNav && wonderBlocksClickable.isClientSideUrl(href) ? React__namespace.createElement(StyledLink, _extends__default["default"]({}, commonProps, {
|
|
158
|
+
to: href,
|
|
159
|
+
ref: ref
|
|
160
|
+
}), child) : React__namespace.createElement(StyledA, _extends__default["default"]({}, commonProps, {
|
|
161
|
+
href: href,
|
|
162
|
+
ref: ref
|
|
163
|
+
}), child);
|
|
164
|
+
} else {
|
|
165
|
+
return React__namespace.createElement(StyledButton, _extends__default["default"]({
|
|
166
|
+
type: type
|
|
167
|
+
}, commonProps, {
|
|
168
|
+
onClick: disabled ? undefined : restProps.onClick,
|
|
169
|
+
"aria-disabled": disabled,
|
|
170
|
+
ref: ref
|
|
171
|
+
}), child);
|
|
172
|
+
}
|
|
176
173
|
});
|
|
177
174
|
const sharedStyles = aphrodite.StyleSheet.create({
|
|
178
175
|
shared: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-icon-button",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,18 +13,19 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@babel/runtime": "^7.24.5",
|
|
16
|
-
"@khanacademy/wonder-blocks-clickable": "
|
|
16
|
+
"@khanacademy/wonder-blocks-clickable": "7.0.0",
|
|
17
17
|
"@khanacademy/wonder-blocks-core": "12.2.1",
|
|
18
18
|
"@khanacademy/wonder-blocks-icon": "5.1.3",
|
|
19
|
-
"@khanacademy/wonder-blocks-styles": "0.2.
|
|
19
|
+
"@khanacademy/wonder-blocks-styles": "0.2.2",
|
|
20
20
|
"@khanacademy/wonder-blocks-theming": "3.2.1",
|
|
21
|
-
"@khanacademy/wonder-blocks-tokens": "
|
|
21
|
+
"@khanacademy/wonder-blocks-tokens": "6.0.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"aphrodite": "^1.2.5",
|
|
25
25
|
"react": "18.2.0",
|
|
26
26
|
"react-router": "5.3.4",
|
|
27
|
-
"react-router-dom": "5.3.4"
|
|
27
|
+
"react-router-dom": "5.3.4",
|
|
28
|
+
"react-router-dom-v5-compat": "^6.30.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@khanacademy/wb-dev-build-settings": "2.1.1"
|