@instructure/ui-range-input 11.7.10 → 11.7.11-pr-snapshot-1794841957152

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.
@@ -1,193 +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 _uiDomUtils = require("@instructure/ui-dom-utils");
13
- var _emotion = require("@instructure/emotion");
14
- var _uiReactUtils = require("@instructure/ui-react-utils");
15
- var _styles = _interopRequireDefault(require("./styles.js"));
16
- var _props = require("./props.js");
17
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
18
- var _dec, _dec2, _class;
19
- /*
20
- * The MIT License (MIT)
21
- *
22
- * Copyright (c) 2015 - present Instructure, Inc.
23
- *
24
- * Permission is hereby granted, free of charge, to any person obtaining a copy
25
- * of this software and associated documentation files (the "Software"), to deal
26
- * in the Software without restriction, including without limitation the rights
27
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28
- * copies of the Software, and to permit persons to whom the Software is
29
- * furnished to do so, subject to the following conditions:
30
- *
31
- * The above copyright notice and this permission notice shall be included in all
32
- * copies or substantial portions of the Software.
33
- *
34
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40
- * SOFTWARE.
41
- */
42
- /**
43
- ---
44
- category: components
45
- ---
46
- **/
47
- let RangeInput = exports.RangeInput = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _emotion.withStyleNew)(_styles.default), _dec(_class = _dec2(_class = class RangeInput extends _react.Component {
48
- static displayName = 'RangeInput';
49
- static componentId = 'RangeInput';
50
- static outputLocatorAttribute = 'data-range-output';
51
- static allowedProps = _props.allowedProps;
52
- static defaultProps = {
53
- step: 1,
54
- formatValue: val => val,
55
- // If min and max has default value, they don't give a warning if not set, even if they are required props.
56
- // TODO: figure out if they don't need to be required or remove defaults in V9.
57
- max: 0,
58
- min: 0,
59
- inline: false,
60
- size: 'medium',
61
- layout: 'stacked',
62
- displayValue: true,
63
- disabled: false,
64
- readOnly: false
65
- };
66
- ref = null;
67
- _input = null;
68
- _inputListener = null;
69
- _changeListener = null;
70
- defaultId;
71
- handleRef = el => {
72
- this.ref = el;
73
- };
74
- handleInputRef = el => {
75
- this._input = el;
76
- if (typeof this.props.inputRef === 'function') {
77
- this.props.inputRef(el);
78
- }
79
- };
80
- constructor(props) {
81
- super(props);
82
- if (typeof props.value === 'undefined') {
83
- this.state = {
84
- value: props.defaultValue
85
- };
86
- }
87
- this.defaultId = props.deterministicId();
88
- }
89
-
90
- /* workaround for https://github.com/facebook/react/issues/554 */
91
- componentDidMount() {
92
- this.props.makeStyles?.();
93
- if (this._input !== null) {
94
- // https://connect.microsoft.com/IE/Feedback/Details/856998
95
- this._inputListener = (0, _uiDomUtils.addEventListener)(this._input, 'input', this.handleChange);
96
- this._changeListener = (0, _uiDomUtils.addEventListener)(this._input, 'change', this.handleChange);
97
- }
98
- }
99
- componentWillUnmount() {
100
- if (!this._input) {
101
- return;
102
- }
103
- this._inputListener?.remove();
104
- this._changeListener?.remove();
105
- }
106
- /* end workaround */
107
-
108
- componentDidUpdate() {
109
- this.props.makeStyles?.();
110
- }
111
- handleChange = event => {
112
- const {
113
- onChange,
114
- value
115
- } = this.props;
116
- if (typeof value === 'undefined') {
117
- this.setState({
118
- value: event.target.value
119
- });
120
- }
121
- if (typeof onChange === 'function') {
122
- onChange(event.target.value);
123
- }
124
- };
125
-
126
- // controlled input must have an onChange, but we're handling it with native events
127
- noopChange = () => {};
128
- get value() {
129
- const value = typeof this.props.value === 'undefined' ? this.state.value : this.props.value;
130
- return typeof value === 'string' ? parseInt(value) : value;
131
- }
132
- get id() {
133
- return this.props.id || this.defaultId;
134
- }
135
- renderValue() {
136
- if (this.props.displayValue) {
137
- if (!this.value) {
138
- (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}`.');
139
- return null;
140
- }
141
- const props = {
142
- [RangeInput.outputLocatorAttribute]: this.id
143
- };
144
- return (0, _jsxRuntime.jsx)(_latest.ContextView, {
145
- background: "inverse",
146
- placement: "end center",
147
- children: (0, _jsxRuntime.jsx)("div", {
148
- ...props,
149
- css: this.props.styles?.rangeInputInputValue,
150
- children: this.props.formatValue(this.value, this.props.max)
151
- })
152
- });
153
- }
154
- return null;
155
- }
156
- render() {
157
- const {
158
- formatValue,
159
- disabled,
160
- readOnly
161
- } = this.props;
162
- const props = (0, _uiReactUtils.omitProps)(this.props, RangeInput.allowedProps);
163
- return (0, _jsxRuntime.jsx)(_latest2.FormField, {
164
- ...(0, _uiReactUtils.pickProps)(this.props, _latest2.FormField.allowedProps),
165
- label: this.props.label,
166
- id: this.id,
167
- elementRef: this.handleRef,
168
- "data-cid": "RangeInput",
169
- children: ({
170
- describedBy
171
- }) => (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
- "aria-describedby": [props['aria-describedby'], describedBy].filter(Boolean).join(' ') || undefined
188
- }), this.renderValue()]
189
- })
190
- });
191
- }
192
- }) || _class) || _class);
193
- var _default = exports.default = RangeInput;
@@ -1,31 +0,0 @@
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 = ['min', 'max', 'defaultValue', 'value', 'onChange', 'messages', 'size', 'layout', 'id', 'label', 'displayValue', 'step', 'formatValue', 'inline', 'disabled', 'readOnly', 'margin', 'inputRef'];
@@ -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
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "RangeInput", {
7
- enumerable: true,
8
- get: function () {
9
- return _index.RangeInput;
10
- }
11
- });
12
- var _index = require("../RangeInput/v1/index.js");
package/lib/exports/b.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "RangeInput", {
7
- enumerable: true,
8
- get: function () {
9
- return _index.RangeInput;
10
- }
11
- });
12
- var _index = require("../RangeInput/v2/index.js");
package/lib/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"commonjs"}