@instructure/ui-tag 10.16.1-snapshot-0 → 10.16.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/CHANGELOG.md +1 -1
- package/es/Tag/__new-tests__/Tag.test.js +13 -11
- package/es/Tag/index.js +18 -14
- package/lib/Tag/__new-tests__/Tag.test.js +17 -16
- package/lib/Tag/index.js +16 -14
- package/package.json +14 -14
- package/src/Tag/__new-tests__/Tag.test.tsx +1 -1
- package/src/Tag/index.tsx +3 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Tag/index.d.ts +2 -4
- package/types/Tag/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [10.16.1
|
|
6
|
+
## [10.16.1](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1) (2025-04-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-tag
|
|
9
9
|
|
|
@@ -23,7 +23,6 @@ var _Tag, _Tag2;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
28
27
|
import { userEvent } from '@testing-library/user-event';
|
|
29
28
|
import '@testing-library/jest-dom';
|
|
@@ -31,6 +30,7 @@ import { vi } from 'vitest';
|
|
|
31
30
|
import { Tag } from '../index';
|
|
32
31
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
33
32
|
import { View } from '@instructure/ui-view';
|
|
33
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
34
34
|
const originalOmitViewProps = View.omitViewProps;
|
|
35
35
|
describe('<Tag />', async () => {
|
|
36
36
|
beforeAll(() => {
|
|
@@ -49,7 +49,7 @@ describe('<Tag />', async () => {
|
|
|
49
49
|
View.omitViewProps = originalOmitViewProps;
|
|
50
50
|
});
|
|
51
51
|
it('should display text', async () => {
|
|
52
|
-
render(_Tag || (_Tag =
|
|
52
|
+
render(_Tag || (_Tag = _jsx(Tag, {
|
|
53
53
|
text: "Summer"
|
|
54
54
|
})));
|
|
55
55
|
const tag = screen.getByText('Summer');
|
|
@@ -57,7 +57,7 @@ describe('<Tag />', async () => {
|
|
|
57
57
|
});
|
|
58
58
|
it('should render as a button and respond to onClick event', async () => {
|
|
59
59
|
const onClick = vi.fn();
|
|
60
|
-
render(
|
|
60
|
+
render(_jsx(Tag, {
|
|
61
61
|
"data-testid": "summer-button",
|
|
62
62
|
text: "Summer",
|
|
63
63
|
onClick: onClick
|
|
@@ -71,7 +71,7 @@ describe('<Tag />', async () => {
|
|
|
71
71
|
});
|
|
72
72
|
it('should render a close icon when it is dismissible and clickable', async () => {
|
|
73
73
|
const onClick = vi.fn();
|
|
74
|
-
const _render = render(
|
|
74
|
+
const _render = render(_jsx(Tag, {
|
|
75
75
|
text: "Summer",
|
|
76
76
|
onClick: onClick,
|
|
77
77
|
dismissible: true
|
|
@@ -81,7 +81,7 @@ describe('<Tag />', async () => {
|
|
|
81
81
|
expect(icon).toHaveAttribute('name', 'IconX');
|
|
82
82
|
});
|
|
83
83
|
it('should meet a11y standards', async () => {
|
|
84
|
-
const _render2 = render(_Tag2 || (_Tag2 =
|
|
84
|
+
const _render2 = render(_Tag2 || (_Tag2 = _jsx(Tag, {
|
|
85
85
|
text: "Summer"
|
|
86
86
|
}))),
|
|
87
87
|
container = _render2.container;
|
|
@@ -100,9 +100,10 @@ describe('<Tag />', async () => {
|
|
|
100
100
|
[prop]: 'foo'
|
|
101
101
|
};
|
|
102
102
|
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
103
|
-
render(
|
|
104
|
-
text: "Summer"
|
|
105
|
-
|
|
103
|
+
render(_jsx(Tag, {
|
|
104
|
+
text: "Summer",
|
|
105
|
+
...props
|
|
106
|
+
}));
|
|
106
107
|
const warning = `Warning: [Tag] prop '${prop}' is not allowed.`;
|
|
107
108
|
expect(consoleError.mock.calls[0][0]).toBe(warning);
|
|
108
109
|
consoleError.mockRestore();
|
|
@@ -113,9 +114,10 @@ describe('<Tag />', async () => {
|
|
|
113
114
|
[prop]: allowedProps[prop]
|
|
114
115
|
};
|
|
115
116
|
const consoleError = vi.spyOn(console, 'error');
|
|
116
|
-
render(
|
|
117
|
-
text: "Summer"
|
|
118
|
-
|
|
117
|
+
render(_jsx(Tag, {
|
|
118
|
+
text: "Summer",
|
|
119
|
+
...props
|
|
120
|
+
}));
|
|
119
121
|
expect(consoleError).not.toHaveBeenCalled();
|
|
120
122
|
consoleError.mockRestore();
|
|
121
123
|
});
|
package/es/Tag/index.js
CHANGED
|
@@ -22,14 +22,14 @@ var _dec, _dec2, _class, _Tag;
|
|
|
22
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
import
|
|
25
|
+
|
|
26
|
+
import { Component } from 'react';
|
|
27
27
|
import { IconXLine } from '@instructure/ui-icons';
|
|
28
28
|
import { View } from '@instructure/ui-view';
|
|
29
29
|
import { omitProps } from '@instructure/ui-react-utils';
|
|
30
30
|
import { isActiveElement } from '@instructure/ui-dom-utils';
|
|
31
31
|
import { testable } from '@instructure/ui-testable';
|
|
32
|
-
import { withStyle
|
|
32
|
+
import { withStyle } from '@instructure/emotion';
|
|
33
33
|
import generateStyle from './styles';
|
|
34
34
|
import generateComponentTheme from './theme';
|
|
35
35
|
import { allowedProps, propTypes } from './props';
|
|
@@ -39,6 +39,7 @@ import { allowedProps, propTypes } from './props';
|
|
|
39
39
|
category: components
|
|
40
40
|
---
|
|
41
41
|
**/
|
|
42
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
42
43
|
let Tag = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_Tag = class Tag extends Component {
|
|
43
44
|
constructor(...args) {
|
|
44
45
|
super(...args);
|
|
@@ -88,24 +89,27 @@ let Tag = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = test
|
|
|
88
89
|
margin = _this$props4.margin,
|
|
89
90
|
styles = _this$props4.styles;
|
|
90
91
|
const passthroughProps = View.omitViewProps(omitProps(this.props, Tag.allowedProps), Tag);
|
|
91
|
-
return
|
|
92
|
+
return _jsxs(View, {
|
|
93
|
+
...passthroughProps,
|
|
92
94
|
elementRef: this.handleRef,
|
|
93
95
|
css: styles === null || styles === void 0 ? void 0 : styles.tag,
|
|
94
96
|
className: className,
|
|
95
97
|
as: onClick ? 'button' : 'span',
|
|
96
98
|
margin: margin,
|
|
97
|
-
type: onClick ? 'button' : void 0
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
type: onClick ? 'button' : void 0,
|
|
100
|
+
...(onClick && {
|
|
101
|
+
onClick: this.handleClick
|
|
102
|
+
}),
|
|
101
103
|
disabled: disabled || readOnly,
|
|
102
104
|
display: void 0,
|
|
103
|
-
title: title || (typeof text === 'string' ? text : void 0)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
title: title || (typeof text === 'string' ? text : void 0),
|
|
106
|
+
children: [_jsx("span", {
|
|
107
|
+
css: styles === null || styles === void 0 ? void 0 : styles.text,
|
|
108
|
+
children: text
|
|
109
|
+
}), onClick && dismissible ? _jsx(IconXLine, {
|
|
110
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
111
|
+
}) : null]
|
|
112
|
+
});
|
|
109
113
|
}
|
|
110
114
|
}, _Tag.displayName = "Tag", _Tag.componentId = 'Tag', _Tag.allowedProps = allowedProps, _Tag.propTypes = propTypes, _Tag.defaultProps = {
|
|
111
115
|
size: 'medium',
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var _react = _interopRequireDefault(require("react"));
|
|
5
|
-
var _react2 = require("@testing-library/react");
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
6
4
|
var _userEvent = require("@testing-library/user-event");
|
|
7
5
|
require("@testing-library/jest-dom");
|
|
8
6
|
var _vitest = require("vitest");
|
|
9
7
|
var _index = require("../index");
|
|
10
8
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
11
9
|
var _View = require("@instructure/ui-view/lib/View");
|
|
10
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
12
11
|
var _Tag, _Tag2;
|
|
13
12
|
/*
|
|
14
13
|
* The MIT License (MIT)
|
|
@@ -51,29 +50,29 @@ describe('<Tag />', async () => {
|
|
|
51
50
|
_View.View.omitViewProps = originalOmitViewProps;
|
|
52
51
|
});
|
|
53
52
|
it('should display text', async () => {
|
|
54
|
-
(0,
|
|
53
|
+
(0, _react.render)(_Tag || (_Tag = (0, _jsxRuntime.jsx)(_index.Tag, {
|
|
55
54
|
text: "Summer"
|
|
56
55
|
})));
|
|
57
|
-
const tag =
|
|
56
|
+
const tag = _react.screen.getByText('Summer');
|
|
58
57
|
expect(tag).toBeInTheDocument();
|
|
59
58
|
});
|
|
60
59
|
it('should render as a button and respond to onClick event', async () => {
|
|
61
60
|
const onClick = _vitest.vi.fn();
|
|
62
|
-
(0,
|
|
61
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.Tag, {
|
|
63
62
|
"data-testid": "summer-button",
|
|
64
63
|
text: "Summer",
|
|
65
64
|
onClick: onClick
|
|
66
65
|
}));
|
|
67
|
-
const button =
|
|
66
|
+
const button = _react.screen.getByTestId('summer-button');
|
|
68
67
|
_userEvent.userEvent.click(button);
|
|
69
|
-
await (0,
|
|
68
|
+
await (0, _react.waitFor)(() => {
|
|
70
69
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
71
70
|
expect(button.tagName).toBe('BUTTON');
|
|
72
71
|
});
|
|
73
72
|
});
|
|
74
73
|
it('should render a close icon when it is dismissible and clickable', async () => {
|
|
75
74
|
const onClick = _vitest.vi.fn();
|
|
76
|
-
const _render = (0,
|
|
75
|
+
const _render = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Tag, {
|
|
77
76
|
text: "Summer",
|
|
78
77
|
onClick: onClick,
|
|
79
78
|
dismissible: true
|
|
@@ -83,7 +82,7 @@ describe('<Tag />', async () => {
|
|
|
83
82
|
expect(icon).toHaveAttribute('name', 'IconX');
|
|
84
83
|
});
|
|
85
84
|
it('should meet a11y standards', async () => {
|
|
86
|
-
const _render2 = (0,
|
|
85
|
+
const _render2 = (0, _react.render)(_Tag2 || (_Tag2 = (0, _jsxRuntime.jsx)(_index.Tag, {
|
|
87
86
|
text: "Summer"
|
|
88
87
|
}))),
|
|
89
88
|
container = _render2.container;
|
|
@@ -102,9 +101,10 @@ describe('<Tag />', async () => {
|
|
|
102
101
|
[prop]: 'foo'
|
|
103
102
|
};
|
|
104
103
|
const consoleError = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
105
|
-
(0,
|
|
106
|
-
text: "Summer"
|
|
107
|
-
|
|
104
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.Tag, {
|
|
105
|
+
text: "Summer",
|
|
106
|
+
...props
|
|
107
|
+
}));
|
|
108
108
|
const warning = `Warning: [Tag] prop '${prop}' is not allowed.`;
|
|
109
109
|
expect(consoleError.mock.calls[0][0]).toBe(warning);
|
|
110
110
|
consoleError.mockRestore();
|
|
@@ -115,9 +115,10 @@ describe('<Tag />', async () => {
|
|
|
115
115
|
[prop]: allowedProps[prop]
|
|
116
116
|
};
|
|
117
117
|
const consoleError = _vitest.vi.spyOn(console, 'error');
|
|
118
|
-
(0,
|
|
119
|
-
text: "Summer"
|
|
120
|
-
|
|
118
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.Tag, {
|
|
119
|
+
text: "Summer",
|
|
120
|
+
...props
|
|
121
|
+
}));
|
|
121
122
|
expect(consoleError).not.toHaveBeenCalled();
|
|
122
123
|
consoleError.mockRestore();
|
|
123
124
|
});
|
package/lib/Tag/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.Tag = void 0;
|
|
9
|
-
var _react =
|
|
8
|
+
var _react = require("react");
|
|
10
9
|
var _IconXLine = require("@instructure/ui-icons/lib/IconXLine.js");
|
|
11
10
|
var _View = require("@instructure/ui-view/lib/View");
|
|
12
11
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
@@ -16,6 +15,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
16
15
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
17
16
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
18
17
|
var _props = require("./props");
|
|
18
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
19
19
|
var _dec, _dec2, _class, _Tag;
|
|
20
20
|
/*
|
|
21
21
|
* The MIT License (MIT)
|
|
@@ -40,7 +40,6 @@ var _dec, _dec2, _class, _Tag;
|
|
|
40
40
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
41
41
|
* SOFTWARE.
|
|
42
42
|
*/
|
|
43
|
-
/** @jsx jsx */
|
|
44
43
|
/**
|
|
45
44
|
---
|
|
46
45
|
category: components
|
|
@@ -95,24 +94,27 @@ let Tag = exports.Tag = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.
|
|
|
95
94
|
margin = _this$props4.margin,
|
|
96
95
|
styles = _this$props4.styles;
|
|
97
96
|
const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, Tag.allowedProps), Tag);
|
|
98
|
-
return (0,
|
|
97
|
+
return (0, _jsxRuntime.jsxs)(_View.View, {
|
|
98
|
+
...passthroughProps,
|
|
99
99
|
elementRef: this.handleRef,
|
|
100
100
|
css: styles === null || styles === void 0 ? void 0 : styles.tag,
|
|
101
101
|
className: className,
|
|
102
102
|
as: onClick ? 'button' : 'span',
|
|
103
103
|
margin: margin,
|
|
104
|
-
type: onClick ? 'button' : void 0
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
type: onClick ? 'button' : void 0,
|
|
105
|
+
...(onClick && {
|
|
106
|
+
onClick: this.handleClick
|
|
107
|
+
}),
|
|
108
108
|
disabled: disabled || readOnly,
|
|
109
109
|
display: void 0,
|
|
110
|
-
title: title || (typeof text === 'string' ? text : void 0)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
title: title || (typeof text === 'string' ? text : void 0),
|
|
111
|
+
children: [(0, _jsxRuntime.jsx)("span", {
|
|
112
|
+
css: styles === null || styles === void 0 ? void 0 : styles.text,
|
|
113
|
+
children: text
|
|
114
|
+
}), onClick && dismissible ? (0, _jsxRuntime.jsx)(_IconXLine.IconXLine, {
|
|
115
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
116
|
+
}) : null]
|
|
117
|
+
});
|
|
116
118
|
}
|
|
117
119
|
}, _Tag.displayName = "Tag", _Tag.componentId = 'Tag', _Tag.allowedProps = _props.allowedProps, _Tag.propTypes = _props.propTypes, _Tag.defaultProps = {
|
|
118
120
|
size: 'medium',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-tag",
|
|
3
|
-
"version": "10.16.1
|
|
3
|
+
"version": "10.16.1",
|
|
4
4
|
"description": "A tag component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,22 +24,22 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.26.0",
|
|
27
|
-
"@instructure/console": "10.16.1
|
|
28
|
-
"@instructure/emotion": "10.16.1
|
|
29
|
-
"@instructure/shared-types": "10.16.1
|
|
30
|
-
"@instructure/ui-color-utils": "10.16.1
|
|
31
|
-
"@instructure/ui-dom-utils": "10.16.1
|
|
32
|
-
"@instructure/ui-icons": "10.16.1
|
|
33
|
-
"@instructure/ui-react-utils": "10.16.1
|
|
34
|
-
"@instructure/ui-testable": "10.16.1
|
|
35
|
-
"@instructure/ui-view": "10.16.1
|
|
27
|
+
"@instructure/console": "10.16.1",
|
|
28
|
+
"@instructure/emotion": "10.16.1",
|
|
29
|
+
"@instructure/shared-types": "10.16.1",
|
|
30
|
+
"@instructure/ui-color-utils": "10.16.1",
|
|
31
|
+
"@instructure/ui-dom-utils": "10.16.1",
|
|
32
|
+
"@instructure/ui-icons": "10.16.1",
|
|
33
|
+
"@instructure/ui-react-utils": "10.16.1",
|
|
34
|
+
"@instructure/ui-testable": "10.16.1",
|
|
35
|
+
"@instructure/ui-view": "10.16.1",
|
|
36
36
|
"prop-types": "^15.8.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@instructure/ui-axe-check": "10.16.1
|
|
40
|
-
"@instructure/ui-babel-preset": "10.16.1
|
|
41
|
-
"@instructure/ui-test-utils": "10.16.1
|
|
42
|
-
"@instructure/ui-themes": "10.16.1
|
|
39
|
+
"@instructure/ui-axe-check": "10.16.1",
|
|
40
|
+
"@instructure/ui-babel-preset": "10.16.1",
|
|
41
|
+
"@instructure/ui-test-utils": "10.16.1",
|
|
42
|
+
"@instructure/ui-themes": "10.16.1",
|
|
43
43
|
"@testing-library/jest-dom": "^6.6.3",
|
|
44
44
|
"@testing-library/react": "^16.0.1",
|
|
45
45
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import
|
|
25
|
+
import { ComponentType } from 'react'
|
|
26
26
|
import { render, screen, waitFor } from '@testing-library/react'
|
|
27
27
|
import { userEvent } from '@testing-library/user-event'
|
|
28
28
|
import '@testing-library/jest-dom'
|
package/src/Tag/index.tsx
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
import
|
|
24
|
+
|
|
25
|
+
import { Component } from 'react'
|
|
26
26
|
|
|
27
27
|
import { IconXLine } from '@instructure/ui-icons'
|
|
28
28
|
import { View } from '@instructure/ui-view'
|
|
@@ -30,7 +30,7 @@ import type { ViewProps } from '@instructure/ui-view'
|
|
|
30
30
|
import { omitProps } from '@instructure/ui-react-utils'
|
|
31
31
|
import { isActiveElement } from '@instructure/ui-dom-utils'
|
|
32
32
|
import { testable } from '@instructure/ui-testable'
|
|
33
|
-
import { withStyle
|
|
33
|
+
import { withStyle } from '@instructure/emotion'
|
|
34
34
|
|
|
35
35
|
import generateStyle from './styles'
|
|
36
36
|
import generateComponentTheme from './theme'
|