@instructure/ui-pill 11.6.0 → 11.6.1-snapshot-129
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 +31 -282
- package/es/Pill/{index.js → v1/index.js} +3 -3
- package/es/Pill/v2/index.js +143 -0
- package/es/Pill/v2/props.js +26 -0
- package/es/Pill/v2/styles.js +101 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/{src/index.ts → es/exports/b.js} +1 -3
- package/lib/Pill/v1/index.js +149 -0
- package/lib/Pill/{index.js → v2/index.js} +5 -6
- package/lib/Pill/v2/props.js +31 -0
- package/lib/Pill/v2/styles.js +107 -0
- package/lib/{index.js → exports/a.js} +2 -2
- package/lib/exports/b.js +12 -0
- package/package.json +47 -25
- package/src/Pill/{index.tsx → v1/index.tsx} +4 -4
- package/src/Pill/v2/README.md +80 -0
- package/src/Pill/v2/index.tsx +183 -0
- package/src/Pill/v2/props.ts +85 -0
- package/src/Pill/v2/styles.ts +110 -0
- package/src/exports/a.ts +26 -0
- package/src/exports/b.ts +26 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Pill/{index.d.ts → v1/index.d.ts} +1 -1
- package/types/Pill/v1/index.d.ts.map +1 -0
- package/types/Pill/v1/props.d.ts.map +1 -0
- package/types/Pill/v1/styles.d.ts.map +1 -0
- package/types/Pill/v1/theme.d.ts.map +1 -0
- package/types/Pill/v2/index.d.ts +36 -0
- package/types/Pill/v2/index.d.ts.map +1 -0
- package/types/Pill/v2/props.d.ts +37 -0
- package/types/Pill/v2/props.d.ts.map +1 -0
- package/types/Pill/v2/styles.d.ts +14 -0
- package/types/Pill/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +3 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +3 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/Pill/index.d.ts.map +0 -1
- package/types/Pill/props.d.ts.map +0 -1
- package/types/Pill/styles.d.ts.map +0 -1
- package/types/Pill/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -3
- package/types/index.d.ts.map +0 -1
- /package/es/Pill/{props.js → v1/props.js} +0 -0
- /package/es/Pill/{styles.js → v1/styles.js} +0 -0
- /package/es/Pill/{theme.js → v1/theme.js} +0 -0
- /package/lib/Pill/{props.js → v1/props.js} +0 -0
- /package/lib/Pill/{styles.js → v1/styles.js} +0 -0
- /package/lib/Pill/{theme.js → v1/theme.js} +0 -0
- /package/src/Pill/{README.md → v1/README.md} +0 -0
- /package/src/Pill/{props.ts → v1/props.ts} +0 -0
- /package/src/Pill/{styles.ts → v1/styles.ts} +0 -0
- /package/src/Pill/{theme.ts → v1/theme.ts} +0 -0
- /package/types/Pill/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/Pill/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Pill/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
const _excluded = ["margin", "children", "color", "as", "elementRef", "styles", "makeStyles", "statusLabel", "renderIcon"];
|
|
3
|
+
var _dec, _class, _Pill;
|
|
4
|
+
/*
|
|
5
|
+
* The MIT License (MIT)
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { Component } from 'react';
|
|
29
|
+
import { View } from '@instructure/ui-view/latest';
|
|
30
|
+
import { passthroughProps } from '@instructure/ui-react-utils';
|
|
31
|
+
import { Tooltip } from '@instructure/ui-tooltip/latest';
|
|
32
|
+
import { withStyle } from '@instructure/emotion';
|
|
33
|
+
import generateStyle from "./styles.js";
|
|
34
|
+
import { allowedProps } from "./props.js";
|
|
35
|
+
/**
|
|
36
|
+
---
|
|
37
|
+
category: components
|
|
38
|
+
---
|
|
39
|
+
**/
|
|
40
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
41
|
+
let Pill = (_dec = withStyle(generateStyle), _dec(_class = (_Pill = class Pill extends Component {
|
|
42
|
+
constructor(props) {
|
|
43
|
+
super(props);
|
|
44
|
+
this.ref = null;
|
|
45
|
+
this.ellipsisRef = null;
|
|
46
|
+
this.handleRef = el => {
|
|
47
|
+
const elementRef = this.props.elementRef;
|
|
48
|
+
this.ref = el;
|
|
49
|
+
if (typeof elementRef === 'function') {
|
|
50
|
+
elementRef(el);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
this.state = {
|
|
54
|
+
truncated: false
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
componentDidMount() {
|
|
58
|
+
var _this$props$makeStyle, _this$props;
|
|
59
|
+
this.setTruncation();
|
|
60
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
61
|
+
}
|
|
62
|
+
componentDidUpdate() {
|
|
63
|
+
var _this$props$makeStyle2, _this$props2;
|
|
64
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
65
|
+
}
|
|
66
|
+
setTruncation() {
|
|
67
|
+
if (this.ellipsisRef) {
|
|
68
|
+
this.setState({
|
|
69
|
+
truncated: this.ellipsisRef.offsetWidth < this.ellipsisRef.scrollWidth
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
renderPill(focused, getTriggerProps) {
|
|
74
|
+
const _this$props3 = this.props,
|
|
75
|
+
margin = _this$props3.margin,
|
|
76
|
+
children = _this$props3.children,
|
|
77
|
+
color = _this$props3.color,
|
|
78
|
+
as = _this$props3.as,
|
|
79
|
+
elementRef = _this$props3.elementRef,
|
|
80
|
+
styles = _this$props3.styles,
|
|
81
|
+
makeStyles = _this$props3.makeStyles,
|
|
82
|
+
statusLabel = _this$props3.statusLabel,
|
|
83
|
+
renderIcon = _this$props3.renderIcon,
|
|
84
|
+
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
85
|
+
const filteredProps = passthroughProps(props);
|
|
86
|
+
const containerProps = typeof getTriggerProps === 'function' ? getTriggerProps(filteredProps) : filteredProps;
|
|
87
|
+
const refProp = this.state.truncated ? {} : {
|
|
88
|
+
elementRef: this.handleRef
|
|
89
|
+
};
|
|
90
|
+
return _jsx(View, {
|
|
91
|
+
...containerProps,
|
|
92
|
+
as: as,
|
|
93
|
+
...refProp,
|
|
94
|
+
margin: margin,
|
|
95
|
+
padding: "0",
|
|
96
|
+
maxWidth: styles === null || styles === void 0 ? void 0 : styles.maxWidth,
|
|
97
|
+
background: "transparent",
|
|
98
|
+
borderRadius: "pill",
|
|
99
|
+
borderWidth: "0",
|
|
100
|
+
display: "inline-block",
|
|
101
|
+
position: "relative",
|
|
102
|
+
withFocusOutline: focused,
|
|
103
|
+
focusColor: "info",
|
|
104
|
+
"data-cid": "Pill",
|
|
105
|
+
children: _jsxs("div", {
|
|
106
|
+
css: styles === null || styles === void 0 ? void 0 : styles.pill,
|
|
107
|
+
children: [renderIcon && _jsx("div", {
|
|
108
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon,
|
|
109
|
+
children: renderIcon
|
|
110
|
+
}), _jsxs("div", {
|
|
111
|
+
css: styles === null || styles === void 0 ? void 0 : styles.text,
|
|
112
|
+
ref: el => {
|
|
113
|
+
this.ellipsisRef = el;
|
|
114
|
+
},
|
|
115
|
+
children: [statusLabel && _jsx("span", {
|
|
116
|
+
css: styles === null || styles === void 0 ? void 0 : styles.status,
|
|
117
|
+
children: statusLabel && statusLabel.concat(':')
|
|
118
|
+
}), children]
|
|
119
|
+
})]
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
render() {
|
|
124
|
+
if (this.state.truncated) {
|
|
125
|
+
return _jsx(Tooltip, {
|
|
126
|
+
renderTip: this.props.statusLabel ? this.props.statusLabel.concat(': ', this.props.children) : this.props.children,
|
|
127
|
+
elementRef: this.handleRef,
|
|
128
|
+
children: ({
|
|
129
|
+
focused,
|
|
130
|
+
getTriggerProps
|
|
131
|
+
}) => {
|
|
132
|
+
return this.renderPill(focused, getTriggerProps);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
} else {
|
|
136
|
+
return this.renderPill();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}, _Pill.displayName = "Pill", _Pill.componentId = 'Pill', _Pill.allowedProps = allowedProps, _Pill.defaultProps = {
|
|
140
|
+
color: 'primary'
|
|
141
|
+
}, _Pill)) || _class);
|
|
142
|
+
export default Pill;
|
|
143
|
+
export { Pill };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const allowedProps = ['as', 'children', 'color', 'elementRef', 'margin'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* ---
|
|
27
|
+
* private: true
|
|
28
|
+
* ---
|
|
29
|
+
* Generates the style object from the theme and provided additional information
|
|
30
|
+
* @param {Object} componentTheme The theme variable object.
|
|
31
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
32
|
+
* @return {Object} The final style object, which will be used in the component
|
|
33
|
+
*/
|
|
34
|
+
const generateStyle = (componentTheme, props) => {
|
|
35
|
+
const color = props.color;
|
|
36
|
+
const pillColorVariants = {
|
|
37
|
+
primary: {
|
|
38
|
+
color: componentTheme.baseTextColor,
|
|
39
|
+
borderColor: componentTheme.baseBorderColor
|
|
40
|
+
},
|
|
41
|
+
success: {
|
|
42
|
+
color: componentTheme.successTextColor,
|
|
43
|
+
borderColor: componentTheme.successBorderColor
|
|
44
|
+
},
|
|
45
|
+
info: {
|
|
46
|
+
color: componentTheme.infoTextColor,
|
|
47
|
+
borderColor: componentTheme.infoBorderColor
|
|
48
|
+
},
|
|
49
|
+
warning: {
|
|
50
|
+
color: componentTheme.warningTextColor,
|
|
51
|
+
borderColor: componentTheme.warningBorderColor
|
|
52
|
+
},
|
|
53
|
+
error: {
|
|
54
|
+
color: componentTheme.errorTextColor,
|
|
55
|
+
borderColor: componentTheme.errorBorderColor
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
pill: {
|
|
60
|
+
label: 'pill',
|
|
61
|
+
display: 'flex',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
boxSizing: 'border-box',
|
|
64
|
+
padding: `0 ${componentTheme.paddingHorizontal}`,
|
|
65
|
+
background: componentTheme.backgroundColor,
|
|
66
|
+
borderWidth: componentTheme.borderWidth,
|
|
67
|
+
borderStyle: componentTheme.borderStyle,
|
|
68
|
+
borderRadius: componentTheme.borderRadius,
|
|
69
|
+
fontFamily: componentTheme.fontFamily,
|
|
70
|
+
height: componentTheme.height,
|
|
71
|
+
lineHeight: componentTheme.lineHeight,
|
|
72
|
+
...pillColorVariants[color]
|
|
73
|
+
},
|
|
74
|
+
status: {
|
|
75
|
+
label: 'pill__status',
|
|
76
|
+
boxSizing: 'border-box',
|
|
77
|
+
fontSize: componentTheme.textFontSize,
|
|
78
|
+
fontWeight: componentTheme.statusLabelFontWeight,
|
|
79
|
+
marginRight: '0.125rem'
|
|
80
|
+
},
|
|
81
|
+
icon: {
|
|
82
|
+
label: 'pill__icon',
|
|
83
|
+
display: 'flex',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
marginRight: '0.375rem',
|
|
86
|
+
fontSize: '0.75rem'
|
|
87
|
+
},
|
|
88
|
+
text: {
|
|
89
|
+
label: 'pill__text',
|
|
90
|
+
boxSizing: 'border-box',
|
|
91
|
+
maxWidth: componentTheme.maxWidth,
|
|
92
|
+
fontSize: componentTheme.textFontSize,
|
|
93
|
+
fontWeight: componentTheme.textFontWeight,
|
|
94
|
+
textOverflow: 'ellipsis',
|
|
95
|
+
whiteSpace: 'nowrap',
|
|
96
|
+
overflow: 'hidden'
|
|
97
|
+
},
|
|
98
|
+
maxWidth: componentTheme.maxWidth
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export default generateStyle;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.Pill = void 0;
|
|
8
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _v11_ = require("@instructure/ui-view/v11_6");
|
|
11
|
+
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
12
|
+
var _v11_2 = require("@instructure/ui-tooltip/v11_6");
|
|
13
|
+
var _emotion = require("@instructure/emotion");
|
|
14
|
+
var _styles = _interopRequireDefault(require("./styles"));
|
|
15
|
+
var _theme = _interopRequireDefault(require("./theme"));
|
|
16
|
+
var _props = require("./props");
|
|
17
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
18
|
+
const _excluded = ["margin", "children", "color", "as", "elementRef", "styles", "makeStyles", "statusLabel", "renderIcon"];
|
|
19
|
+
var _dec, _class, _Pill;
|
|
20
|
+
/*
|
|
21
|
+
* The MIT License (MIT)
|
|
22
|
+
*
|
|
23
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
24
|
+
*
|
|
25
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
26
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
27
|
+
* in the Software without restriction, including without limitation the rights
|
|
28
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
29
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
30
|
+
* furnished to do so, subject to the following conditions:
|
|
31
|
+
*
|
|
32
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
33
|
+
* copies or substantial portions of the Software.
|
|
34
|
+
*
|
|
35
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
36
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
37
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
38
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
39
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
40
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
41
|
+
* SOFTWARE.
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
---
|
|
45
|
+
category: components
|
|
46
|
+
---
|
|
47
|
+
**/
|
|
48
|
+
let Pill = exports.Pill = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = (_Pill = class Pill extends _react.Component {
|
|
49
|
+
constructor(props) {
|
|
50
|
+
super(props);
|
|
51
|
+
this.ref = null;
|
|
52
|
+
this.ellipsisRef = null;
|
|
53
|
+
this.handleRef = el => {
|
|
54
|
+
const elementRef = this.props.elementRef;
|
|
55
|
+
this.ref = el;
|
|
56
|
+
if (typeof elementRef === 'function') {
|
|
57
|
+
elementRef(el);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
this.state = {
|
|
61
|
+
truncated: false
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
componentDidMount() {
|
|
65
|
+
var _this$props$makeStyle, _this$props;
|
|
66
|
+
this.setTruncation();
|
|
67
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
68
|
+
}
|
|
69
|
+
componentDidUpdate() {
|
|
70
|
+
var _this$props$makeStyle2, _this$props2;
|
|
71
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
72
|
+
}
|
|
73
|
+
setTruncation() {
|
|
74
|
+
if (this.ellipsisRef) {
|
|
75
|
+
this.setState({
|
|
76
|
+
truncated: this.ellipsisRef.offsetWidth < this.ellipsisRef.scrollWidth
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
renderPill(focused, getTriggerProps) {
|
|
81
|
+
const _this$props3 = this.props,
|
|
82
|
+
margin = _this$props3.margin,
|
|
83
|
+
children = _this$props3.children,
|
|
84
|
+
color = _this$props3.color,
|
|
85
|
+
as = _this$props3.as,
|
|
86
|
+
elementRef = _this$props3.elementRef,
|
|
87
|
+
styles = _this$props3.styles,
|
|
88
|
+
makeStyles = _this$props3.makeStyles,
|
|
89
|
+
statusLabel = _this$props3.statusLabel,
|
|
90
|
+
renderIcon = _this$props3.renderIcon,
|
|
91
|
+
props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
92
|
+
const filteredProps = (0, _passthroughProps.passthroughProps)(props);
|
|
93
|
+
const containerProps = typeof getTriggerProps === 'function' ? getTriggerProps(filteredProps) : filteredProps;
|
|
94
|
+
const refProp = this.state.truncated ? {} : {
|
|
95
|
+
elementRef: this.handleRef
|
|
96
|
+
};
|
|
97
|
+
return (0, _jsxRuntime.jsx)(_v11_.View, {
|
|
98
|
+
...containerProps,
|
|
99
|
+
as: as,
|
|
100
|
+
...refProp,
|
|
101
|
+
margin: margin,
|
|
102
|
+
padding: "0",
|
|
103
|
+
maxWidth: styles === null || styles === void 0 ? void 0 : styles.maxWidth,
|
|
104
|
+
background: "transparent",
|
|
105
|
+
borderRadius: "pill",
|
|
106
|
+
borderWidth: "0",
|
|
107
|
+
display: "inline-block",
|
|
108
|
+
position: "relative",
|
|
109
|
+
withFocusOutline: focused,
|
|
110
|
+
focusColor: "info",
|
|
111
|
+
"data-cid": "Pill",
|
|
112
|
+
children: (0, _jsxRuntime.jsxs)("div", {
|
|
113
|
+
css: styles === null || styles === void 0 ? void 0 : styles.pill,
|
|
114
|
+
children: [renderIcon && (0, _jsxRuntime.jsx)("div", {
|
|
115
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon,
|
|
116
|
+
children: renderIcon
|
|
117
|
+
}), (0, _jsxRuntime.jsxs)("div", {
|
|
118
|
+
css: styles === null || styles === void 0 ? void 0 : styles.text,
|
|
119
|
+
ref: el => {
|
|
120
|
+
this.ellipsisRef = el;
|
|
121
|
+
},
|
|
122
|
+
children: [statusLabel && (0, _jsxRuntime.jsx)("span", {
|
|
123
|
+
css: styles === null || styles === void 0 ? void 0 : styles.status,
|
|
124
|
+
children: statusLabel && statusLabel.concat(':')
|
|
125
|
+
}), children]
|
|
126
|
+
})]
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
render() {
|
|
131
|
+
if (this.state.truncated) {
|
|
132
|
+
return (0, _jsxRuntime.jsx)(_v11_2.Tooltip, {
|
|
133
|
+
renderTip: this.props.statusLabel ? this.props.statusLabel.concat(': ', this.props.children) : this.props.children,
|
|
134
|
+
elementRef: this.handleRef,
|
|
135
|
+
children: ({
|
|
136
|
+
focused,
|
|
137
|
+
getTriggerProps
|
|
138
|
+
}) => {
|
|
139
|
+
return this.renderPill(focused, getTriggerProps);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
return this.renderPill();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, _Pill.displayName = "Pill", _Pill.componentId = 'Pill', _Pill.allowedProps = _props.allowedProps, _Pill.defaultProps = {
|
|
147
|
+
color: 'primary'
|
|
148
|
+
}, _Pill)) || _class);
|
|
149
|
+
var _default = exports.default = Pill;
|
|
@@ -7,12 +7,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.Pill = void 0;
|
|
8
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
9
|
var _react = require("react");
|
|
10
|
-
var
|
|
10
|
+
var _latest = require("@instructure/ui-view/latest");
|
|
11
11
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
12
|
-
var
|
|
12
|
+
var _latest2 = require("@instructure/ui-tooltip/latest");
|
|
13
13
|
var _emotion = require("@instructure/emotion");
|
|
14
14
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
15
|
-
var _theme = _interopRequireDefault(require("./theme"));
|
|
16
15
|
var _props = require("./props");
|
|
17
16
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
18
17
|
const _excluded = ["margin", "children", "color", "as", "elementRef", "styles", "makeStyles", "statusLabel", "renderIcon"];
|
|
@@ -45,7 +44,7 @@ var _dec, _class, _Pill;
|
|
|
45
44
|
category: components
|
|
46
45
|
---
|
|
47
46
|
**/
|
|
48
|
-
let Pill = exports.Pill = (_dec = (0, _emotion.withStyle)(_styles.default
|
|
47
|
+
let Pill = exports.Pill = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = (_Pill = class Pill extends _react.Component {
|
|
49
48
|
constructor(props) {
|
|
50
49
|
super(props);
|
|
51
50
|
this.ref = null;
|
|
@@ -94,7 +93,7 @@ let Pill = exports.Pill = (_dec = (0, _emotion.withStyle)(_styles.default, _them
|
|
|
94
93
|
const refProp = this.state.truncated ? {} : {
|
|
95
94
|
elementRef: this.handleRef
|
|
96
95
|
};
|
|
97
|
-
return (0, _jsxRuntime.jsx)(
|
|
96
|
+
return (0, _jsxRuntime.jsx)(_latest.View, {
|
|
98
97
|
...containerProps,
|
|
99
98
|
as: as,
|
|
100
99
|
...refProp,
|
|
@@ -129,7 +128,7 @@ let Pill = exports.Pill = (_dec = (0, _emotion.withStyle)(_styles.default, _them
|
|
|
129
128
|
}
|
|
130
129
|
render() {
|
|
131
130
|
if (this.state.truncated) {
|
|
132
|
-
return (0, _jsxRuntime.jsx)(
|
|
131
|
+
return (0, _jsxRuntime.jsx)(_latest2.Tooltip, {
|
|
133
132
|
renderTip: this.props.statusLabel ? this.props.statusLabel.concat(': ', this.props.children) : this.props.children,
|
|
134
133
|
elementRef: this.handleRef,
|
|
135
134
|
children: ({
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.allowedProps = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const allowedProps = exports.allowedProps = ['as', 'children', 'color', 'elementRef', 'margin'];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ---
|
|
33
|
+
* private: true
|
|
34
|
+
* ---
|
|
35
|
+
* Generates the style object from the theme and provided additional information
|
|
36
|
+
* @param {Object} componentTheme The theme variable object.
|
|
37
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
38
|
+
* @return {Object} The final style object, which will be used in the component
|
|
39
|
+
*/
|
|
40
|
+
const generateStyle = (componentTheme, props) => {
|
|
41
|
+
const color = props.color;
|
|
42
|
+
const pillColorVariants = {
|
|
43
|
+
primary: {
|
|
44
|
+
color: componentTheme.baseTextColor,
|
|
45
|
+
borderColor: componentTheme.baseBorderColor
|
|
46
|
+
},
|
|
47
|
+
success: {
|
|
48
|
+
color: componentTheme.successTextColor,
|
|
49
|
+
borderColor: componentTheme.successBorderColor
|
|
50
|
+
},
|
|
51
|
+
info: {
|
|
52
|
+
color: componentTheme.infoTextColor,
|
|
53
|
+
borderColor: componentTheme.infoBorderColor
|
|
54
|
+
},
|
|
55
|
+
warning: {
|
|
56
|
+
color: componentTheme.warningTextColor,
|
|
57
|
+
borderColor: componentTheme.warningBorderColor
|
|
58
|
+
},
|
|
59
|
+
error: {
|
|
60
|
+
color: componentTheme.errorTextColor,
|
|
61
|
+
borderColor: componentTheme.errorBorderColor
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
pill: {
|
|
66
|
+
label: 'pill',
|
|
67
|
+
display: 'flex',
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
boxSizing: 'border-box',
|
|
70
|
+
padding: `0 ${componentTheme.paddingHorizontal}`,
|
|
71
|
+
background: componentTheme.backgroundColor,
|
|
72
|
+
borderWidth: componentTheme.borderWidth,
|
|
73
|
+
borderStyle: componentTheme.borderStyle,
|
|
74
|
+
borderRadius: componentTheme.borderRadius,
|
|
75
|
+
fontFamily: componentTheme.fontFamily,
|
|
76
|
+
height: componentTheme.height,
|
|
77
|
+
lineHeight: componentTheme.lineHeight,
|
|
78
|
+
...pillColorVariants[color]
|
|
79
|
+
},
|
|
80
|
+
status: {
|
|
81
|
+
label: 'pill__status',
|
|
82
|
+
boxSizing: 'border-box',
|
|
83
|
+
fontSize: componentTheme.textFontSize,
|
|
84
|
+
fontWeight: componentTheme.statusLabelFontWeight,
|
|
85
|
+
marginRight: '0.125rem'
|
|
86
|
+
},
|
|
87
|
+
icon: {
|
|
88
|
+
label: 'pill__icon',
|
|
89
|
+
display: 'flex',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
marginRight: '0.375rem',
|
|
92
|
+
fontSize: '0.75rem'
|
|
93
|
+
},
|
|
94
|
+
text: {
|
|
95
|
+
label: 'pill__text',
|
|
96
|
+
boxSizing: 'border-box',
|
|
97
|
+
maxWidth: componentTheme.maxWidth,
|
|
98
|
+
fontSize: componentTheme.textFontSize,
|
|
99
|
+
fontWeight: componentTheme.textFontWeight,
|
|
100
|
+
textOverflow: 'ellipsis',
|
|
101
|
+
whiteSpace: 'nowrap',
|
|
102
|
+
overflow: 'hidden'
|
|
103
|
+
},
|
|
104
|
+
maxWidth: componentTheme.maxWidth
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
var _default = exports.default = generateStyle;
|
package/lib/exports/b.js
ADDED