@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
|
@@ -6,6 +6,7 @@ category: components
|
|
|
6
6
|
---
|
|
7
7
|
**/
|
|
8
8
|
declare class RangeInput extends Component<RangeInputProps, RangeInputState> {
|
|
9
|
+
static displayName: string;
|
|
9
10
|
static readonly componentId = "RangeInput";
|
|
10
11
|
static outputLocatorAttribute: string;
|
|
11
12
|
static allowedProps: readonly (keyof {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/RangeInput/v1/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAgBjC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG/D;;;;GAIG;AACH,cAEM,UAAW,SAAQ,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAClE,MAAM,CAAC,QAAQ,CAAC,WAAW,gBAAe;IAC1C,MAAM,CAAC,sBAAsB,SAAsB;IAEnD,MAAM,CAAC,YAAY;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/RangeInput/v1/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAgBjC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG/D;;;;GAIG;AACH,cAEM,UAAW,SAAQ,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAClE,MAAM,CAAC,WAAW,SAAe;IACjC,MAAM,CAAC,QAAQ,CAAC,WAAW,gBAAe;IAC1C,MAAM,CAAC,sBAAsB,SAAsB;IAEnD,MAAM,CAAC,YAAY;;;;;;;;;;;;;4BAOwC,CAAC,aAAa,CAAC;;;;;;SAPxC;IAElC,MAAM,CAAC,YAAY;;4BAEG,MAAM;;;;;;;;;;MAc3B;IAED,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,cAAc,CAAkC;IACxD,OAAO,CAAC,eAAe,CAAkC;IACzD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAElC,SAAS,GAAI,IAAI,OAAO,GAAG,IAAI,UAE9B;IAED,cAAc,GAAI,IAAI,gBAAgB,GAAG,IAAI,UAK5C;gBAEW,KAAK,EAAE,eAAe;IAalC,iBAAiB;IAkBjB,oBAAoB;IASpB,kBAAkB;IAIlB,YAAY,GAAI,OAAO,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,UAUzD;IAGD,UAAU,EAAE,KAAK,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAW;IAEjE,IAAI,KAAK,uBAOR;IAED,IAAI,EAAE,WAEL;IAED,WAAW;IAsBX,MAAM;CAkCP;AAED,eAAe,UAAU,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
|
@@ -6,6 +6,7 @@ category: components
|
|
|
6
6
|
---
|
|
7
7
|
**/
|
|
8
8
|
declare class RangeInput extends Component<RangeInputProps, RangeInputState> {
|
|
9
|
+
static displayName: string;
|
|
9
10
|
static readonly componentId = "RangeInput";
|
|
10
11
|
static outputLocatorAttribute: string;
|
|
11
12
|
static allowedProps: readonly (keyof {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/RangeInput/v2/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAejC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG/D;;;;GAIG;AACH,cAEM,UAAW,SAAQ,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAClE,MAAM,CAAC,QAAQ,CAAC,WAAW,gBAAe;IAC1C,MAAM,CAAC,sBAAsB,SAAsB;IAEnD,MAAM,CAAC,YAAY;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/RangeInput/v2/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAejC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG/D;;;;GAIG;AACH,cAEM,UAAW,SAAQ,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAClE,MAAM,CAAC,WAAW,SAAe;IACjC,MAAM,CAAC,QAAQ,CAAC,WAAW,gBAAe;IAC1C,MAAM,CAAC,sBAAsB,SAAsB;IAEnD,MAAM,CAAC,YAAY;;;;;;;;;;;;;4BAcjB,CAAC,aAAa,CAAC;;;;;SAdiB;IAElC,MAAM,CAAC,YAAY;;4BAEG,MAAM;;;;;;;;;MAa3B;IAED,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,cAAc,CAAkC;IACxD,OAAO,CAAC,eAAe,CAAkC;IACzD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAElC,SAAS,GAAI,IAAI,OAAO,GAAG,IAAI,UAE9B;IAED,cAAc,GAAI,IAAI,gBAAgB,GAAG,IAAI,UAK5C;gBAEW,KAAK,EAAE,eAAe;IAalC,iBAAiB;IAkBjB,oBAAoB;IASpB,kBAAkB;IAIlB,YAAY,GAAI,OAAO,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,UAUzD;IAGD,UAAU,EAAE,KAAK,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAW;IAEjE,IAAI,KAAK,uBAOR;IAED,IAAI,EAAE,WAEL;IAED,WAAW;IAsBX,MAAM;CAkCP;AAED,eAAe,UAAU,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
package/types/exports/a.d.ts
CHANGED
package/types/exports/a.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../../src/exports/a.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../../src/exports/a.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA"}
|
package/types/exports/b.d.ts
CHANGED
package/types/exports/b.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"b.d.ts","sourceRoot":"","sources":["../../src/exports/b.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"b.d.ts","sourceRoot":"","sources":["../../src/exports/b.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -1,194 +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 _v11_ = require("@instructure/ui-view/v11_6");
|
|
11
|
-
var _v11_2 = require("@instructure/ui-form-field/v11_6");
|
|
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 _theme = _interopRequireDefault(require("./theme"));
|
|
19
|
-
var _props = require("./props");
|
|
20
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
21
|
-
var _dec, _dec2, _class;
|
|
22
|
-
/*
|
|
23
|
-
* The MIT License (MIT)
|
|
24
|
-
*
|
|
25
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
26
|
-
*
|
|
27
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
28
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
29
|
-
* in the Software without restriction, including without limitation the rights
|
|
30
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
31
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
32
|
-
* furnished to do so, subject to the following conditions:
|
|
33
|
-
*
|
|
34
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
35
|
-
* copies or substantial portions of the Software.
|
|
36
|
-
*
|
|
37
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
38
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
39
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
40
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
41
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
42
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
43
|
-
* SOFTWARE.
|
|
44
|
-
*/
|
|
45
|
-
/**
|
|
46
|
-
---
|
|
47
|
-
category: components
|
|
48
|
-
---
|
|
49
|
-
**/
|
|
50
|
-
let RangeInput = exports.RangeInput = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = _dec2(_class = class RangeInput extends _react.Component {
|
|
51
|
-
static displayName = "RangeInput";
|
|
52
|
-
static componentId = 'RangeInput';
|
|
53
|
-
static outputLocatorAttribute = 'data-range-output';
|
|
54
|
-
static allowedProps = _props.allowedProps;
|
|
55
|
-
static defaultProps = {
|
|
56
|
-
step: 1,
|
|
57
|
-
formatValue: val => val,
|
|
58
|
-
// If min and max has default value, they don't give a warning if not set, even if they are required props.
|
|
59
|
-
// TODO: figure out if they don't need to be required or remove defaults in V9.
|
|
60
|
-
max: 0,
|
|
61
|
-
min: 0,
|
|
62
|
-
inline: false,
|
|
63
|
-
size: 'medium',
|
|
64
|
-
layout: 'stacked',
|
|
65
|
-
displayValue: true,
|
|
66
|
-
disabled: false,
|
|
67
|
-
readOnly: false,
|
|
68
|
-
thumbVariant: 'deprecated'
|
|
69
|
-
};
|
|
70
|
-
ref = null;
|
|
71
|
-
_input = null;
|
|
72
|
-
_inputListener = null;
|
|
73
|
-
_changeListener = null;
|
|
74
|
-
defaultId;
|
|
75
|
-
handleRef = el => {
|
|
76
|
-
this.ref = el;
|
|
77
|
-
};
|
|
78
|
-
handleInputRef = el => {
|
|
79
|
-
this._input = el;
|
|
80
|
-
if (typeof this.props.inputRef === 'function') {
|
|
81
|
-
this.props.inputRef(el);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
constructor(props) {
|
|
85
|
-
super(props);
|
|
86
|
-
if (typeof props.value === 'undefined') {
|
|
87
|
-
this.state = {
|
|
88
|
-
value: props.defaultValue
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
this.defaultId = props.deterministicId();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/* workaround for https://github.com/facebook/react/issues/554 */
|
|
95
|
-
componentDidMount() {
|
|
96
|
-
this.props.makeStyles?.();
|
|
97
|
-
if (this._input !== null) {
|
|
98
|
-
// https://connect.microsoft.com/IE/Feedback/Details/856998
|
|
99
|
-
this._inputListener = (0, _addEventListener.addEventListener)(this._input, 'input', this.handleChange);
|
|
100
|
-
this._changeListener = (0, _addEventListener.addEventListener)(this._input, 'change', this.handleChange);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
componentWillUnmount() {
|
|
104
|
-
if (!this._input) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
this._inputListener?.remove();
|
|
108
|
-
this._changeListener?.remove();
|
|
109
|
-
}
|
|
110
|
-
/* end workaround */
|
|
111
|
-
|
|
112
|
-
componentDidUpdate() {
|
|
113
|
-
this.props.makeStyles?.();
|
|
114
|
-
}
|
|
115
|
-
handleChange = event => {
|
|
116
|
-
const {
|
|
117
|
-
onChange,
|
|
118
|
-
value
|
|
119
|
-
} = this.props;
|
|
120
|
-
if (typeof value === 'undefined') {
|
|
121
|
-
this.setState({
|
|
122
|
-
value: event.target.value
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
if (typeof onChange === 'function') {
|
|
126
|
-
onChange(event.target.value);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// controlled input must have an onChange, but we're handling it with native events
|
|
131
|
-
noopChange = () => {};
|
|
132
|
-
get value() {
|
|
133
|
-
const value = typeof this.props.value === 'undefined' ? this.state.value : this.props.value;
|
|
134
|
-
return typeof value === 'string' ? parseInt(value) : value;
|
|
135
|
-
}
|
|
136
|
-
get id() {
|
|
137
|
-
return this.props.id || this.defaultId;
|
|
138
|
-
}
|
|
139
|
-
renderValue() {
|
|
140
|
-
if (this.props.displayValue) {
|
|
141
|
-
if (!this.value) {
|
|
142
|
-
(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}`.');
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
const props = {
|
|
146
|
-
[RangeInput.outputLocatorAttribute]: this.id
|
|
147
|
-
};
|
|
148
|
-
return (0, _jsxRuntime.jsx)(_v11_.ContextView, {
|
|
149
|
-
background: "inverse",
|
|
150
|
-
placement: "end center",
|
|
151
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
152
|
-
...props,
|
|
153
|
-
css: this.props.styles?.rangeInputInputValue,
|
|
154
|
-
children: this.props.formatValue(this.value, this.props.max)
|
|
155
|
-
})
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
render() {
|
|
161
|
-
const {
|
|
162
|
-
formatValue,
|
|
163
|
-
disabled,
|
|
164
|
-
readOnly
|
|
165
|
-
} = this.props;
|
|
166
|
-
const props = (0, _omitProps.omitProps)(this.props, RangeInput.allowedProps);
|
|
167
|
-
return (0, _jsxRuntime.jsx)(_v11_2.FormField, {
|
|
168
|
-
...(0, _pickProps.pickProps)(this.props, _v11_2.FormField.allowedProps),
|
|
169
|
-
label: this.props.label,
|
|
170
|
-
id: this.id,
|
|
171
|
-
elementRef: this.handleRef,
|
|
172
|
-
"data-cid": "RangeInput",
|
|
173
|
-
children: (0, _jsxRuntime.jsxs)("div", {
|
|
174
|
-
css: this.props.styles?.rangeInput,
|
|
175
|
-
children: [(0, _jsxRuntime.jsx)("input", {
|
|
176
|
-
css: this.props.styles?.rangeInputInput,
|
|
177
|
-
ref: this.handleInputRef,
|
|
178
|
-
type: "range",
|
|
179
|
-
id: this.id,
|
|
180
|
-
min: this.props.min,
|
|
181
|
-
max: this.props.max,
|
|
182
|
-
step: this.props.step,
|
|
183
|
-
value: this.value,
|
|
184
|
-
onChange: this.noopChange,
|
|
185
|
-
"aria-valuetext": formatValue(this.value, this.props.max),
|
|
186
|
-
...props,
|
|
187
|
-
disabled: disabled || readOnly,
|
|
188
|
-
"aria-disabled": disabled || readOnly ? 'true' : undefined
|
|
189
|
-
}), this.renderValue()]
|
|
190
|
-
})
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}) || _class) || _class);
|
|
194
|
-
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', 'thumbVariant', 'inputRef'];
|
|
@@ -1,169 +0,0 @@
|
|
|
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
|
-
* @param {Object} state the state of the component, the style is applied to
|
|
39
|
-
* @return {Object} The final style object, which will be used in the component
|
|
40
|
-
*/
|
|
41
|
-
const generateStyle = (componentTheme, props) => {
|
|
42
|
-
const {
|
|
43
|
-
size,
|
|
44
|
-
thumbVariant
|
|
45
|
-
} = props;
|
|
46
|
-
const valueSizeVariants = {
|
|
47
|
-
small: {
|
|
48
|
-
fontSize: componentTheme.valueSmallFontSize,
|
|
49
|
-
padding: componentTheme.valueSmallPadding,
|
|
50
|
-
lineHeight: componentTheme.valueSmallLineHeight
|
|
51
|
-
},
|
|
52
|
-
medium: {
|
|
53
|
-
fontSize: componentTheme.valueMediumFontSize,
|
|
54
|
-
padding: componentTheme.valueMediumPadding,
|
|
55
|
-
lineHeight: componentTheme.valueMediumLineHeight
|
|
56
|
-
},
|
|
57
|
-
large: {
|
|
58
|
-
fontSize: componentTheme.valueLargeFontSize,
|
|
59
|
-
padding: componentTheme.valueLargePadding,
|
|
60
|
-
lineHeight: componentTheme.valueLargeLineHeight
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const trackStyle = {
|
|
64
|
-
borderRadius: '0.312em',
|
|
65
|
-
borderColor: 'transparent',
|
|
66
|
-
color: 'transparent',
|
|
67
|
-
cursor: 'pointer',
|
|
68
|
-
background: componentTheme.trackBackground,
|
|
69
|
-
height: `calc(${componentTheme.handleSize} / 2)`
|
|
70
|
-
};
|
|
71
|
-
const borderedHandleSize = `calc(${componentTheme.handleSize} + (${componentTheme.handleBorderSize} * 2))`;
|
|
72
|
-
const thumbVariantStyle = {
|
|
73
|
-
deprecated: {
|
|
74
|
-
width: componentTheme.handleSize,
|
|
75
|
-
height: componentTheme.handleSize,
|
|
76
|
-
boxShadow: `0 0.0625rem 0 ${componentTheme.handleShadowColor}`
|
|
77
|
-
},
|
|
78
|
-
accessible: {
|
|
79
|
-
width: borderedHandleSize,
|
|
80
|
-
height: borderedHandleSize,
|
|
81
|
-
borderWidth: componentTheme.handleBorderSize,
|
|
82
|
-
borderColor: componentTheme.handleBorderColor,
|
|
83
|
-
borderStyle: 'solid',
|
|
84
|
-
boxSizing: 'border-box',
|
|
85
|
-
boxShadow: componentTheme.handleShadow
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
const thumbStyle = {
|
|
89
|
-
appearance: 'none',
|
|
90
|
-
borderRadius: '50%',
|
|
91
|
-
cursor: 'pointer',
|
|
92
|
-
transition: 'all 0.15s ease-in-out',
|
|
93
|
-
background: componentTheme.handleBackground,
|
|
94
|
-
...thumbVariantStyle[thumbVariant],
|
|
95
|
-
'&:hover': {
|
|
96
|
-
background: componentTheme.handleHoverBackground
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const thumbPosition = {
|
|
100
|
-
deprecated: {
|
|
101
|
-
marginTop: `calc(-1 * ${componentTheme.handleSize} / 4)`
|
|
102
|
-
},
|
|
103
|
-
accessible: {
|
|
104
|
-
marginTop: `calc(-1 * ${borderedHandleSize} / 4)`
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
const thumbFocusActiveStyle = {
|
|
108
|
-
deprecated: {
|
|
109
|
-
background: componentTheme.handleFocusBackground,
|
|
110
|
-
boxShadow: `0 0.0625rem 0 ${componentTheme.handleShadowColor}, 0 0 0 ${componentTheme.handleFocusOutlineWidth} ${componentTheme.handleFocusOutlineColor}`
|
|
111
|
-
},
|
|
112
|
-
accessible: {
|
|
113
|
-
background: componentTheme.handleFocusBackground,
|
|
114
|
-
boxShadow: componentTheme.handleShadow + ', ' + `inset 0 0 0 ${componentTheme.handleFocusInset} ${componentTheme.handleFocusBackground}, ` + `inset 0 0 0 calc(${componentTheme.handleFocusInset} + ${componentTheme.handleFocusRingSize}) ${componentTheme.handleFocusRingColor}`
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
return {
|
|
118
|
-
rangeInput: {
|
|
119
|
-
label: 'rangeInput',
|
|
120
|
-
display: 'flex',
|
|
121
|
-
justifyContent: 'center',
|
|
122
|
-
alignItems: 'center',
|
|
123
|
-
minWidth: componentTheme.minWidth
|
|
124
|
-
},
|
|
125
|
-
rangeInputInput: {
|
|
126
|
-
label: 'rangeInput__input',
|
|
127
|
-
all: 'initial',
|
|
128
|
-
flex: 'auto',
|
|
129
|
-
boxSizing: 'border-box',
|
|
130
|
-
appearance: 'none',
|
|
131
|
-
width: '100%',
|
|
132
|
-
// for Firefox
|
|
133
|
-
outline: 'none',
|
|
134
|
-
margin: 0,
|
|
135
|
-
'&::-webkit-slider-thumb': {
|
|
136
|
-
...thumbStyle,
|
|
137
|
-
...thumbPosition[thumbVariant]
|
|
138
|
-
},
|
|
139
|
-
'&::-moz-range-thumb': thumbStyle,
|
|
140
|
-
'&:focus, &:active': {
|
|
141
|
-
outline: 'none',
|
|
142
|
-
'&::-webkit-slider-thumb': thumbFocusActiveStyle[thumbVariant],
|
|
143
|
-
'&::-moz-range-thumb': thumbFocusActiveStyle[thumbVariant]
|
|
144
|
-
},
|
|
145
|
-
// remove outline in FF
|
|
146
|
-
'&::-moz-focus-inner, &::-moz-focus-outer': {
|
|
147
|
-
border: 0,
|
|
148
|
-
outline: 'none'
|
|
149
|
-
},
|
|
150
|
-
'&::-webkit-slider-runnable-track': trackStyle,
|
|
151
|
-
'&::-moz-range-track': trackStyle,
|
|
152
|
-
'[dir="rtl"] &': {
|
|
153
|
-
direction: 'rtl'
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
rangeInputInputValue: {
|
|
157
|
-
label: 'rangeInput__value',
|
|
158
|
-
all: 'initial',
|
|
159
|
-
boxSizing: 'border-box',
|
|
160
|
-
display: 'block',
|
|
161
|
-
color: 'inherit',
|
|
162
|
-
fontFamily: componentTheme.valueFontFamily,
|
|
163
|
-
fontWeight: componentTheme.valueFontWeight,
|
|
164
|
-
textAlign: 'center',
|
|
165
|
-
...valueSizeVariants[size]
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
};
|
|
169
|
-
var _default = exports.default = generateStyle;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _alpha = require("@instructure/ui-color-utils/lib/alpha.js");
|
|
8
|
-
var _darken = require("@instructure/ui-color-utils/lib/darken.js");
|
|
9
|
-
/*
|
|
10
|
-
* The MIT License (MIT)
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
19
|
-
* furnished to do so, subject to the following conditions:
|
|
20
|
-
*
|
|
21
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
22
|
-
* copies or substantial portions of the Software.
|
|
23
|
-
*
|
|
24
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
-
* SOFTWARE.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Generates the theme object for the component from the theme and provided additional information
|
|
35
|
-
* @param {Object} theme The actual theme object.
|
|
36
|
-
* @return {Object} The final theme object with the overrides and component variables
|
|
37
|
-
*/
|
|
38
|
-
const generateComponentTheme = theme => {
|
|
39
|
-
const {
|
|
40
|
-
colors,
|
|
41
|
-
borders,
|
|
42
|
-
typography,
|
|
43
|
-
spacing,
|
|
44
|
-
forms,
|
|
45
|
-
key: themeName
|
|
46
|
-
} = theme;
|
|
47
|
-
const themeSpecificStyle = {
|
|
48
|
-
canvas: {
|
|
49
|
-
handleBackground: theme['ic-brand-primary'],
|
|
50
|
-
handleHoverBackground: theme['ic-brand-primary'],
|
|
51
|
-
handleFocusBackground: theme['ic-brand-primary'],
|
|
52
|
-
// Deprecated, remove with "deprecated" thumbVariant
|
|
53
|
-
handleShadowColor: (0, _darken.darken)(theme['ic-brand-primary'], 15),
|
|
54
|
-
handleFocusOutlineColor: (0, _alpha.alpha)(theme['ic-brand-primary'], 40)
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const componentVariables = {
|
|
58
|
-
minWidth: '12.5rem',
|
|
59
|
-
handleSize: '1.5rem',
|
|
60
|
-
handleBackground: colors?.contrasts?.blue4570,
|
|
61
|
-
handleBorderColor: colors?.contrasts?.white1010,
|
|
62
|
-
handleBorderSize: borders?.widthMedium,
|
|
63
|
-
handleShadow: '0 0.0625rem 0.125rem rgba(0, 0, 0, .2), 0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.1)',
|
|
64
|
-
handleFocusInset: borders?.widthSmall,
|
|
65
|
-
handleFocusRingSize: borders?.widthMedium,
|
|
66
|
-
handleFocusRingColor: colors?.contrasts?.white1010,
|
|
67
|
-
handleFocusBackground: colors?.contrasts?.blue4570,
|
|
68
|
-
handleHoverBackground: colors?.contrasts?.blue4570,
|
|
69
|
-
// Deprecated, remove with "deprecated" thumbVariant
|
|
70
|
-
handleShadowColor: (0, _darken.darken)(colors?.contrasts?.blue5782, 10),
|
|
71
|
-
handleFocusOutlineColor: (0, _alpha.alpha)(colors?.contrasts?.blue4570, 40),
|
|
72
|
-
handleFocusOutlineWidth: '0.75em',
|
|
73
|
-
trackBackground: colors?.contrasts?.grey4570,
|
|
74
|
-
valueColor: colors?.contrasts?.white1010,
|
|
75
|
-
valueFontFamily: typography?.fontFamily,
|
|
76
|
-
valueFontWeight: typography?.fontWeightNormal,
|
|
77
|
-
valueSmallFontSize: typography?.fontSizeSmall,
|
|
78
|
-
valueSmallPadding: `0 ${spacing?.xSmall}`,
|
|
79
|
-
valueSmallLineHeight: forms?.inputHeightSmall,
|
|
80
|
-
valueMediumFontSize: typography?.fontSizeMedium,
|
|
81
|
-
valueMediumPadding: `0 ${spacing?.small}`,
|
|
82
|
-
valueMediumLineHeight: forms?.inputHeightMedium,
|
|
83
|
-
valueLargeFontSize: typography?.fontSizeLarge,
|
|
84
|
-
valueLargePadding: `0 ${spacing?.medium}`,
|
|
85
|
-
valueLargeLineHeight: forms?.inputHeightLarge
|
|
86
|
-
};
|
|
87
|
-
return {
|
|
88
|
-
...componentVariables,
|
|
89
|
-
...themeSpecificStyle[themeName]
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
var _default = exports.default = generateComponentTheme;
|