@instructure/ui-range-input 11.7.3 → 11.7.4-pr-snapshot-1781695314229
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 +8 -0
- package/LICENSE.md +1 -0
- package/{lib/RangeInput/v2/props.js → babel.config.cjs} +12 -7
- package/es/RangeInput/v1/index.js +5 -4
- package/es/RangeInput/v2/index.js +4 -3
- package/es/exports/a.js +2 -1
- package/es/exports/b.js +2 -1
- package/package.json +17 -22
- package/src/RangeInput/v1/index.tsx +4 -3
- package/src/RangeInput/v2/index.tsx +3 -2
- package/src/exports/a.ts +1 -1
- package/src/exports/b.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/RangeInput/v1/index.d.ts +1 -0
- package/types/RangeInput/v1/index.d.ts.map +1 -1
- package/types/RangeInput/v2/index.d.ts +1 -0
- package/types/RangeInput/v2/index.d.ts.map +1 -1
- package/types/exports/a.d.ts +1 -1
- package/types/exports/a.d.ts.map +1 -1
- package/types/exports/b.d.ts +1 -1
- package/types/exports/b.d.ts.map +1 -1
- package/lib/RangeInput/v1/index.js +0 -194
- package/lib/RangeInput/v1/props.js +0 -31
- package/lib/RangeInput/v1/styles.js +0 -169
- package/lib/RangeInput/v1/theme.js +0 -92
- package/lib/RangeInput/v2/index.js +0 -192
- package/lib/RangeInput/v2/styles.js +0 -153
- package/lib/exports/a.js +0 -12
- package/lib/exports/b.js +0 -12
- package/lib/package.json +0 -1
|
@@ -1,192 +0,0 @@
|
|
|
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.RangeInput = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _console = require("@instructure/console");
|
|
10
|
-
var _latest = require("@instructure/ui-view/latest");
|
|
11
|
-
var _latest2 = require("@instructure/ui-form-field/latest");
|
|
12
|
-
var _addEventListener = require("@instructure/ui-dom-utils/lib/addEventListener.js");
|
|
13
|
-
var _emotion = require("@instructure/emotion");
|
|
14
|
-
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
15
|
-
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
16
|
-
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
17
|
-
var _styles = _interopRequireDefault(require("./styles"));
|
|
18
|
-
var _props = require("./props");
|
|
19
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
20
|
-
var _dec, _dec2, _class;
|
|
21
|
-
/*
|
|
22
|
-
* The MIT License (MIT)
|
|
23
|
-
*
|
|
24
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
25
|
-
*
|
|
26
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
27
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
28
|
-
* in the Software without restriction, including without limitation the rights
|
|
29
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
30
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
31
|
-
* furnished to do so, subject to the following conditions:
|
|
32
|
-
*
|
|
33
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
34
|
-
* copies or substantial portions of the Software.
|
|
35
|
-
*
|
|
36
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
37
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
38
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
39
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
40
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
41
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
42
|
-
* SOFTWARE.
|
|
43
|
-
*/
|
|
44
|
-
/**
|
|
45
|
-
---
|
|
46
|
-
category: components
|
|
47
|
-
---
|
|
48
|
-
**/
|
|
49
|
-
let RangeInput = exports.RangeInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyleNew)(_styles.default), _dec(_class = _dec2(_class = class RangeInput extends _react.Component {
|
|
50
|
-
static displayName = "RangeInput";
|
|
51
|
-
static componentId = 'RangeInput';
|
|
52
|
-
static outputLocatorAttribute = 'data-range-output';
|
|
53
|
-
static allowedProps = _props.allowedProps;
|
|
54
|
-
static defaultProps = {
|
|
55
|
-
step: 1,
|
|
56
|
-
formatValue: val => val,
|
|
57
|
-
// If min and max has default value, they don't give a warning if not set, even if they are required props.
|
|
58
|
-
// TODO: figure out if they don't need to be required or remove defaults in V9.
|
|
59
|
-
max: 0,
|
|
60
|
-
min: 0,
|
|
61
|
-
inline: false,
|
|
62
|
-
size: 'medium',
|
|
63
|
-
layout: 'stacked',
|
|
64
|
-
displayValue: true,
|
|
65
|
-
disabled: false,
|
|
66
|
-
readOnly: false
|
|
67
|
-
};
|
|
68
|
-
ref = null;
|
|
69
|
-
_input = null;
|
|
70
|
-
_inputListener = null;
|
|
71
|
-
_changeListener = null;
|
|
72
|
-
defaultId;
|
|
73
|
-
handleRef = el => {
|
|
74
|
-
this.ref = el;
|
|
75
|
-
};
|
|
76
|
-
handleInputRef = el => {
|
|
77
|
-
this._input = el;
|
|
78
|
-
if (typeof this.props.inputRef === 'function') {
|
|
79
|
-
this.props.inputRef(el);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
constructor(props) {
|
|
83
|
-
super(props);
|
|
84
|
-
if (typeof props.value === 'undefined') {
|
|
85
|
-
this.state = {
|
|
86
|
-
value: props.defaultValue
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
this.defaultId = props.deterministicId();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/* workaround for https://github.com/facebook/react/issues/554 */
|
|
93
|
-
componentDidMount() {
|
|
94
|
-
this.props.makeStyles?.();
|
|
95
|
-
if (this._input !== null) {
|
|
96
|
-
// https://connect.microsoft.com/IE/Feedback/Details/856998
|
|
97
|
-
this._inputListener = (0, _addEventListener.addEventListener)(this._input, 'input', this.handleChange);
|
|
98
|
-
this._changeListener = (0, _addEventListener.addEventListener)(this._input, 'change', this.handleChange);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
componentWillUnmount() {
|
|
102
|
-
if (!this._input) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
this._inputListener?.remove();
|
|
106
|
-
this._changeListener?.remove();
|
|
107
|
-
}
|
|
108
|
-
/* end workaround */
|
|
109
|
-
|
|
110
|
-
componentDidUpdate() {
|
|
111
|
-
this.props.makeStyles?.();
|
|
112
|
-
}
|
|
113
|
-
handleChange = event => {
|
|
114
|
-
const {
|
|
115
|
-
onChange,
|
|
116
|
-
value
|
|
117
|
-
} = this.props;
|
|
118
|
-
if (typeof value === 'undefined') {
|
|
119
|
-
this.setState({
|
|
120
|
-
value: event.target.value
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
if (typeof onChange === 'function') {
|
|
124
|
-
onChange(event.target.value);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
// controlled input must have an onChange, but we're handling it with native events
|
|
129
|
-
noopChange = () => {};
|
|
130
|
-
get value() {
|
|
131
|
-
const value = typeof this.props.value === 'undefined' ? this.state.value : this.props.value;
|
|
132
|
-
return typeof value === 'string' ? parseInt(value) : value;
|
|
133
|
-
}
|
|
134
|
-
get id() {
|
|
135
|
-
return this.props.id || this.defaultId;
|
|
136
|
-
}
|
|
137
|
-
renderValue() {
|
|
138
|
-
if (this.props.displayValue) {
|
|
139
|
-
if (!this.value) {
|
|
140
|
-
(0, _console.warn)(false, 'RangeInput should have a `value` or `defaultValue` set for the value to be displayed. If no value has to be displayed, set `displayValue={false}`.');
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
const props = {
|
|
144
|
-
[RangeInput.outputLocatorAttribute]: this.id
|
|
145
|
-
};
|
|
146
|
-
return (0, _jsxRuntime.jsx)(_latest.ContextView, {
|
|
147
|
-
background: "inverse",
|
|
148
|
-
placement: "end center",
|
|
149
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
150
|
-
...props,
|
|
151
|
-
css: this.props.styles?.rangeInputInputValue,
|
|
152
|
-
children: this.props.formatValue(this.value, this.props.max)
|
|
153
|
-
})
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
render() {
|
|
159
|
-
const {
|
|
160
|
-
formatValue,
|
|
161
|
-
disabled,
|
|
162
|
-
readOnly
|
|
163
|
-
} = this.props;
|
|
164
|
-
const props = (0, _omitProps.omitProps)(this.props, RangeInput.allowedProps);
|
|
165
|
-
return (0, _jsxRuntime.jsx)(_latest2.FormField, {
|
|
166
|
-
...(0, _pickProps.pickProps)(this.props, _latest2.FormField.allowedProps),
|
|
167
|
-
label: this.props.label,
|
|
168
|
-
id: this.id,
|
|
169
|
-
elementRef: this.handleRef,
|
|
170
|
-
"data-cid": "RangeInput",
|
|
171
|
-
children: (0, _jsxRuntime.jsxs)("div", {
|
|
172
|
-
css: this.props.styles?.rangeInput,
|
|
173
|
-
children: [(0, _jsxRuntime.jsx)("input", {
|
|
174
|
-
css: this.props.styles?.rangeInputInput,
|
|
175
|
-
ref: this.handleInputRef,
|
|
176
|
-
type: "range",
|
|
177
|
-
id: this.id,
|
|
178
|
-
min: this.props.min,
|
|
179
|
-
max: this.props.max,
|
|
180
|
-
step: this.props.step,
|
|
181
|
-
value: this.value,
|
|
182
|
-
onChange: this.noopChange,
|
|
183
|
-
"aria-valuetext": formatValue(this.value, this.props.max),
|
|
184
|
-
...props,
|
|
185
|
-
disabled: disabled || readOnly,
|
|
186
|
-
"aria-disabled": disabled || readOnly ? 'true' : undefined
|
|
187
|
-
}), this.renderValue()]
|
|
188
|
-
})
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}) || _class) || _class);
|
|
192
|
-
var _default = exports.default = RangeInput;
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _uiThemes = require("@instructure/ui-themes");
|
|
8
|
-
/*
|
|
9
|
-
* The MIT License (MIT)
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
-
*
|
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
-
* in the Software without restriction, including without limitation the rights
|
|
16
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
-
* furnished to do so, subject to the following conditions:
|
|
19
|
-
*
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
-
* copies or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
-
* SOFTWARE.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* ---
|
|
34
|
-
* private: true
|
|
35
|
-
* ---
|
|
36
|
-
* Generates the style object from the theme and provided additional information
|
|
37
|
-
* @param {Object} componentTheme The theme variable object.
|
|
38
|
-
* @param {Object} props the props of the component, the style is applied to
|
|
39
|
-
* @param {Object} state the state of the component, the style is applied to
|
|
40
|
-
* @return {Object} The final style object, which will be used in the component
|
|
41
|
-
*/
|
|
42
|
-
const generateStyle = (componentTheme, props, sharedTokens) => {
|
|
43
|
-
const {
|
|
44
|
-
size
|
|
45
|
-
} = props;
|
|
46
|
-
const valueSizeVariants = {
|
|
47
|
-
small: {
|
|
48
|
-
fontSize: componentTheme.valueSmallFontSize,
|
|
49
|
-
paddingInline: componentTheme.valueSmallPadding,
|
|
50
|
-
lineHeight: componentTheme.valueSmallLineHeight
|
|
51
|
-
},
|
|
52
|
-
medium: {
|
|
53
|
-
fontSize: componentTheme.valueMediumFontSize,
|
|
54
|
-
paddingInline: componentTheme.valueMediumPadding,
|
|
55
|
-
lineHeight: componentTheme.valueMediumLineHeight
|
|
56
|
-
},
|
|
57
|
-
large: {
|
|
58
|
-
fontSize: componentTheme.valueLargeFontSize,
|
|
59
|
-
paddingInline: componentTheme.valueLargePadding,
|
|
60
|
-
lineHeight: componentTheme.valueLargeLineHeight
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const trackBorderWidth = '1px';
|
|
64
|
-
const trackStyle = {
|
|
65
|
-
borderRadius: '0.312em',
|
|
66
|
-
borderWidth: trackBorderWidth,
|
|
67
|
-
borderStyle: 'solid',
|
|
68
|
-
borderColor: componentTheme.trackBorderColor,
|
|
69
|
-
color: 'transparent',
|
|
70
|
-
cursor: 'pointer',
|
|
71
|
-
background: componentTheme.trackBackground,
|
|
72
|
-
height: `calc(${componentTheme.handleSize} / 2)`
|
|
73
|
-
};
|
|
74
|
-
const borderedHandleSize = `calc(${componentTheme.handleSize} + (${componentTheme.handleBorderSize} * 2))`;
|
|
75
|
-
const thumbStyle = {
|
|
76
|
-
appearance: 'none',
|
|
77
|
-
borderRadius: '50%',
|
|
78
|
-
cursor: 'pointer',
|
|
79
|
-
transition: 'all 0.15s ease-in-out',
|
|
80
|
-
background: componentTheme.handleBackground,
|
|
81
|
-
width: borderedHandleSize,
|
|
82
|
-
height: borderedHandleSize,
|
|
83
|
-
borderWidth: componentTheme.handleBorderSize,
|
|
84
|
-
borderColor: componentTheme.handleBorderColor,
|
|
85
|
-
borderStyle: 'solid',
|
|
86
|
-
boxSizing: 'border-box',
|
|
87
|
-
boxShadow: (0, _uiThemes.boxShadowObjectsToCSSString)(componentTheme.boxShadow),
|
|
88
|
-
'&:hover': {
|
|
89
|
-
background: componentTheme.handleHoverBackground
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// Center the thumb vertically on the track by accounting for the track borders
|
|
94
|
-
const thumbPosition = {
|
|
95
|
-
marginTop: `calc(-1 * ${borderedHandleSize} / 4 - ${trackBorderWidth})`
|
|
96
|
-
};
|
|
97
|
-
const thumbFocusActiveStyle = {
|
|
98
|
-
background: componentTheme.handleFocusBackground,
|
|
99
|
-
boxShadow: `${(0, _uiThemes.boxShadowObjectsToCSSString)(componentTheme.boxShadow)}, ` + `inset 0 0 0 ${componentTheme.handleFocusInset} ${componentTheme.handleFocusBackground}, ` + `inset 0 0 0 calc(${componentTheme.handleFocusInset} + ${sharedTokens.focusOutline.width}) ${sharedTokens.focusOutline.onColor}`
|
|
100
|
-
};
|
|
101
|
-
return {
|
|
102
|
-
rangeInput: {
|
|
103
|
-
label: 'rangeInput',
|
|
104
|
-
display: 'flex',
|
|
105
|
-
justifyContent: 'center',
|
|
106
|
-
alignItems: 'center',
|
|
107
|
-
minWidth: componentTheme.minWidth
|
|
108
|
-
},
|
|
109
|
-
rangeInputInput: {
|
|
110
|
-
label: 'rangeInput__input',
|
|
111
|
-
all: 'initial',
|
|
112
|
-
flex: 'auto',
|
|
113
|
-
boxSizing: 'border-box',
|
|
114
|
-
appearance: 'none',
|
|
115
|
-
width: '100%',
|
|
116
|
-
// for Firefox
|
|
117
|
-
outline: 'none',
|
|
118
|
-
margin: 0,
|
|
119
|
-
'&::-webkit-slider-thumb': {
|
|
120
|
-
...thumbStyle,
|
|
121
|
-
...thumbPosition
|
|
122
|
-
},
|
|
123
|
-
'&::-moz-range-thumb': thumbStyle,
|
|
124
|
-
'&:focus, &:active': {
|
|
125
|
-
outline: 'none',
|
|
126
|
-
'&::-webkit-slider-thumb': thumbFocusActiveStyle,
|
|
127
|
-
'&::-moz-range-thumb': thumbFocusActiveStyle
|
|
128
|
-
},
|
|
129
|
-
// remove outline in FF
|
|
130
|
-
'&::-moz-focus-inner, &::-moz-focus-outer': {
|
|
131
|
-
border: 0,
|
|
132
|
-
outline: 'none'
|
|
133
|
-
},
|
|
134
|
-
'&::-webkit-slider-runnable-track': trackStyle,
|
|
135
|
-
'&::-moz-range-track': trackStyle,
|
|
136
|
-
'[dir="rtl"] &': {
|
|
137
|
-
direction: 'rtl'
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
rangeInputInputValue: {
|
|
141
|
-
label: 'rangeInput__value',
|
|
142
|
-
all: 'initial',
|
|
143
|
-
boxSizing: 'border-box',
|
|
144
|
-
display: 'block',
|
|
145
|
-
color: 'inherit',
|
|
146
|
-
fontFamily: componentTheme.valueFontFamily,
|
|
147
|
-
fontWeight: componentTheme.valueFontWeight,
|
|
148
|
-
textAlign: 'center',
|
|
149
|
-
...valueSizeVariants[size]
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
var _default = exports.default = generateStyle;
|
package/lib/exports/a.js
DELETED
package/lib/exports/b.js
DELETED
package/lib/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|