@khanacademy/wonder-blocks-clickable 2.1.1 → 2.2.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/dist/es/index.js +352 -643
- package/dist/index.js +592 -721
- package/package.json +9 -8
- package/src/components/__tests__/clickable-behavior.test.js +5 -2
- package/src/components/__tests__/clickable.test.js +18 -12
- package/src/components/clickable-behavior.js +6 -8
- package/src/components/clickable.js +16 -13
- package/src/components/clickable.md +7 -0
- package/src/components/clickable.stories.js +5 -7
- package/src/util/get-clickable-behavior.js +2 -2
- package/src/__tests__/index.test.js +0 -20
package/dist/index.js
CHANGED
|
@@ -82,7 +82,7 @@ module.exports =
|
|
|
82
82
|
/******/
|
|
83
83
|
/******/
|
|
84
84
|
/******/ // Load entry module and return exports
|
|
85
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 11);
|
|
86
86
|
/******/ })
|
|
87
87
|
/************************************************************************/
|
|
88
88
|
/******/ ([
|
|
@@ -93,261 +93,35 @@ module.exports = require("react");
|
|
|
93
93
|
|
|
94
94
|
/***/ }),
|
|
95
95
|
/* 1 */
|
|
96
|
-
/***/ (function(module, exports) {
|
|
97
|
-
|
|
98
|
-
module.exports = require("react-router-dom");
|
|
99
|
-
|
|
100
|
-
/***/ }),
|
|
101
|
-
/* 2 */
|
|
102
|
-
/***/ (function(module, exports) {
|
|
103
|
-
|
|
104
|
-
module.exports = require("@khanacademy/wonder-blocks-core");
|
|
105
|
-
|
|
106
|
-
/***/ }),
|
|
107
|
-
/* 3 */
|
|
108
|
-
/***/ (function(module, exports) {
|
|
109
|
-
|
|
110
|
-
module.exports = require("aphrodite");
|
|
111
|
-
|
|
112
|
-
/***/ }),
|
|
113
|
-
/* 4 */
|
|
114
|
-
/***/ (function(module, exports) {
|
|
115
|
-
|
|
116
|
-
module.exports = require("prop-types");
|
|
117
|
-
|
|
118
|
-
/***/ }),
|
|
119
|
-
/* 5 */
|
|
120
96
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
121
97
|
|
|
122
98
|
"use strict";
|
|
123
|
-
|
|
124
|
-
__webpack_require__.r(__webpack_exports__);
|
|
125
|
-
|
|
126
|
-
// EXPORTS
|
|
127
|
-
__webpack_require__.d(__webpack_exports__, "ClickableBehavior", function() { return /* reexport */ clickable_behavior_ClickableBehavior; });
|
|
128
|
-
__webpack_require__.d(__webpack_exports__, "getClickableBehavior", function() { return /* reexport */ getClickableBehavior; });
|
|
129
|
-
__webpack_require__.d(__webpack_exports__, "isClientSideUrl", function() { return /* reexport */ isClientSideUrl; });
|
|
130
|
-
__webpack_require__.d(__webpack_exports__, "default", function() { return /* reexport */ clickable_Clickable; });
|
|
131
|
-
|
|
132
|
-
// EXTERNAL MODULE: external "react"
|
|
133
|
-
var external_react_ = __webpack_require__(0);
|
|
134
|
-
|
|
135
|
-
// EXTERNAL MODULE: external "aphrodite"
|
|
136
|
-
var external_aphrodite_ = __webpack_require__(3);
|
|
137
|
-
|
|
138
|
-
// EXTERNAL MODULE: external "prop-types"
|
|
139
|
-
var external_prop_types_ = __webpack_require__(4);
|
|
140
|
-
|
|
141
|
-
// EXTERNAL MODULE: external "react-router-dom"
|
|
142
|
-
var external_react_router_dom_ = __webpack_require__(1);
|
|
143
|
-
|
|
144
|
-
// EXTERNAL MODULE: external "@khanacademy/wonder-blocks-core"
|
|
145
|
-
var wonder_blocks_core_ = __webpack_require__(2);
|
|
146
|
-
|
|
147
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-color/dist/es/index.js
|
|
148
|
-
function _defineProperty(obj, key, value) {
|
|
149
|
-
if (key in obj) {
|
|
150
|
-
Object.defineProperty(obj, key, {
|
|
151
|
-
value: value,
|
|
152
|
-
enumerable: true,
|
|
153
|
-
configurable: true,
|
|
154
|
-
writable: true
|
|
155
|
-
});
|
|
156
|
-
} else {
|
|
157
|
-
obj[key] = value;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return obj;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function ownKeys(object, enumerableOnly) {
|
|
164
|
-
var keys = Object.keys(object);
|
|
165
|
-
|
|
166
|
-
if (Object.getOwnPropertySymbols) {
|
|
167
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
168
|
-
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
169
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
170
|
-
});
|
|
171
|
-
keys.push.apply(keys, symbols);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return keys;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function _objectSpread2(target) {
|
|
178
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
179
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
180
|
-
|
|
181
|
-
if (i % 2) {
|
|
182
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
183
|
-
_defineProperty(target, key, source[key]);
|
|
184
|
-
});
|
|
185
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
186
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
187
|
-
} else {
|
|
188
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
189
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return target;
|
|
195
|
-
}
|
|
99
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return isClientSideUrl; });
|
|
196
100
|
/**
|
|
197
|
-
*
|
|
198
|
-
*
|
|
101
|
+
* Returns:
|
|
102
|
+
* - false for hrefs staring with http://, https://, //.
|
|
103
|
+
* - false for '#', 'javascript:...', 'mailto:...', 'tel:...', etc.
|
|
104
|
+
* - true for all other values, e.g. /foo/bar
|
|
199
105
|
*/
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
var color3Regexp = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i;
|
|
204
|
-
var rgbaRegexp = /^rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\s*\)$/i; // Parse a color in #abcdef, rgb(...), or rgba(...) form into an object
|
|
205
|
-
// with r,g,b,a keys.
|
|
206
|
-
|
|
207
|
-
var parse = function parse(color) {
|
|
208
|
-
if (typeof color !== "string") {
|
|
209
|
-
throw new Error("Failed to parse color: ".concat(color));
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
var color3Match = color.match(color3Regexp);
|
|
213
|
-
|
|
214
|
-
if (color3Match) {
|
|
215
|
-
return {
|
|
216
|
-
r: parseInt("".concat(color3Match[1]).concat(color3Match[1]), 16),
|
|
217
|
-
g: parseInt("".concat(color3Match[2]).concat(color3Match[2]), 16),
|
|
218
|
-
b: parseInt("".concat(color3Match[3]).concat(color3Match[3]), 16),
|
|
219
|
-
a: 1
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
var color6Match = color.match(color6Regexp);
|
|
224
|
-
|
|
225
|
-
if (color6Match) {
|
|
226
|
-
return {
|
|
227
|
-
r: parseInt(color6Match[1], 16),
|
|
228
|
-
g: parseInt(color6Match[2], 16),
|
|
229
|
-
b: parseInt(color6Match[3], 16),
|
|
230
|
-
a: 1
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
var rgbaMatch = color.match(rgbaRegexp);
|
|
235
|
-
|
|
236
|
-
if (rgbaMatch) {
|
|
237
|
-
return {
|
|
238
|
-
r: parseFloat(rgbaMatch[1]),
|
|
239
|
-
g: parseFloat(rgbaMatch[2]),
|
|
240
|
-
b: parseFloat(rgbaMatch[3]),
|
|
241
|
-
a: rgbaMatch[4] ? parseFloat(rgbaMatch[4]) : 1
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
throw new Error("Failed to parse color: ".concat(color));
|
|
246
|
-
}; // Stringify the color in an `rgba()` or `#abcdef` format.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
var format = function format(color) {
|
|
250
|
-
var r = Math.round(color.r);
|
|
251
|
-
var g = Math.round(color.g);
|
|
252
|
-
var b = Math.round(color.b);
|
|
253
|
-
|
|
254
|
-
if (color.a === 1) {
|
|
255
|
-
var _s = function _s(c) {
|
|
256
|
-
var asString = c.toString(16);
|
|
257
|
-
return asString.length === 1 ? asString + asString : asString;
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
return "#".concat(_s(r)).concat(_s(g)).concat(_s(b));
|
|
261
|
-
} else {
|
|
262
|
-
return "rgba(".concat(r, ",").concat(g, ",").concat(b, ",").concat(color.a.toFixed(2), ")");
|
|
263
|
-
}
|
|
264
|
-
}; // Adjust the alpha value of a color.
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
var fade = function fade(color, percentage) {
|
|
268
|
-
if (percentage < 0 || percentage > 1) {
|
|
269
|
-
throw new Error("Percentage must be between 0 and 1");
|
|
106
|
+
const isClientSideUrl = href => {
|
|
107
|
+
if (typeof href !== "string") {
|
|
108
|
+
return false;
|
|
270
109
|
}
|
|
271
110
|
|
|
272
|
-
|
|
273
|
-
return format(_objectSpread2(_objectSpread2({}, components), {}, {
|
|
274
|
-
a: components.a * percentage
|
|
275
|
-
}));
|
|
276
|
-
}; // Mix a color into a background color, using the alpha channel of the base
|
|
277
|
-
// color to determine the linear blend.
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
var mix = function mix(color, background) {
|
|
281
|
-
var colorObj = parse(color);
|
|
282
|
-
var bgObj = parse(background);
|
|
283
|
-
return format({
|
|
284
|
-
r: colorObj.r * colorObj.a + bgObj.r * (1 - colorObj.a),
|
|
285
|
-
g: colorObj.g * colorObj.a + bgObj.g * (1 - colorObj.a),
|
|
286
|
-
b: colorObj.b * colorObj.a + bgObj.b * (1 - colorObj.a),
|
|
287
|
-
a: bgObj.a
|
|
288
|
-
});
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
var offBlack = "#21242c";
|
|
292
|
-
var white = "#ffffff";
|
|
293
|
-
var Color = {
|
|
294
|
-
// Product
|
|
295
|
-
blue: "#1865f2",
|
|
296
|
-
purple: "#9059ff",
|
|
297
|
-
green: "#00a60e",
|
|
298
|
-
gold: "#ffb100",
|
|
299
|
-
red: "#d92916",
|
|
300
|
-
// Neutral
|
|
301
|
-
offBlack: offBlack,
|
|
302
|
-
offBlack64: fade(offBlack, 0.64),
|
|
303
|
-
offBlack50: fade(offBlack, 0.5),
|
|
304
|
-
offBlack32: fade(offBlack, 0.32),
|
|
305
|
-
offBlack16: fade(offBlack, 0.16),
|
|
306
|
-
offBlack8: fade(offBlack, 0.08),
|
|
307
|
-
offWhite: "#f7f8fa",
|
|
308
|
-
white: white,
|
|
309
|
-
white64: fade(white, 0.64),
|
|
310
|
-
white50: fade(white, 0.5),
|
|
311
|
-
// Brand
|
|
312
|
-
darkBlue: "#0a2a66",
|
|
313
|
-
teal: "#14bf96",
|
|
314
|
-
lightBlue: "#37c5fd",
|
|
315
|
-
pink: "#fa50ae"
|
|
316
|
-
};
|
|
317
|
-
var SemanticColor = {
|
|
318
|
-
controlDefault: Color.blue,
|
|
319
|
-
controlDestructive: Color.red
|
|
111
|
+
return !/^(https?:)?\/\//i.test(href) && !/^([^#]*#[\w-]*|[\w\-.]+:)/.test(href);
|
|
320
112
|
};
|
|
321
|
-
/* harmony default export */ var es = (Color);
|
|
322
|
-
|
|
323
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-clickable/src/components/clickable-behavior.js
|
|
324
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
325
|
-
|
|
326
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
327
|
-
|
|
328
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
329
|
-
|
|
330
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
331
113
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
337
|
-
|
|
338
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
339
|
-
|
|
340
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
341
|
-
|
|
342
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
343
|
-
|
|
344
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
345
|
-
|
|
346
|
-
function clickable_behavior_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
114
|
+
/***/ }),
|
|
115
|
+
/* 2 */
|
|
116
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
347
117
|
|
|
118
|
+
"use strict";
|
|
119
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ClickableBehavior; });
|
|
120
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
121
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
348
122
|
// NOTE: Potentially add to this as more cases come up.
|
|
349
123
|
|
|
350
|
-
|
|
124
|
+
const getAppropriateTriggersForRole = role => {
|
|
351
125
|
switch (role) {
|
|
352
126
|
// Triggers on ENTER, but not SPACE
|
|
353
127
|
case "link":
|
|
@@ -378,53 +152,27 @@ var getAppropriateTriggersForRole = function getAppropriateTriggersForRole(role)
|
|
|
378
152
|
}
|
|
379
153
|
};
|
|
380
154
|
|
|
381
|
-
|
|
382
|
-
onClick:
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return void 0;
|
|
396
|
-
},
|
|
397
|
-
onDragStart: function onDragStart() {
|
|
398
|
-
return void 0;
|
|
399
|
-
},
|
|
400
|
-
onTouchStart: function onTouchStart() {
|
|
401
|
-
return void 0;
|
|
402
|
-
},
|
|
403
|
-
onTouchEnd: function onTouchEnd() {
|
|
404
|
-
return void 0;
|
|
405
|
-
},
|
|
406
|
-
onTouchCancel: function onTouchCancel() {
|
|
407
|
-
return void 0;
|
|
408
|
-
},
|
|
409
|
-
onKeyDown: function onKeyDown() {
|
|
410
|
-
return void 0;
|
|
411
|
-
},
|
|
412
|
-
onKeyUp: function onKeyUp() {
|
|
413
|
-
return void 0;
|
|
414
|
-
},
|
|
415
|
-
onFocus: function onFocus() {
|
|
416
|
-
return void 0;
|
|
417
|
-
},
|
|
418
|
-
onBlur: function onBlur() {
|
|
419
|
-
return void 0;
|
|
420
|
-
},
|
|
155
|
+
const disabledHandlers = {
|
|
156
|
+
onClick: () => void 0,
|
|
157
|
+
onMouseEnter: () => void 0,
|
|
158
|
+
onMouseLeave: () => void 0,
|
|
159
|
+
onMouseDown: () => void 0,
|
|
160
|
+
onMouseUp: () => void 0,
|
|
161
|
+
onDragStart: () => void 0,
|
|
162
|
+
onTouchStart: () => void 0,
|
|
163
|
+
onTouchEnd: () => void 0,
|
|
164
|
+
onTouchCancel: () => void 0,
|
|
165
|
+
onKeyDown: () => void 0,
|
|
166
|
+
onKeyUp: () => void 0,
|
|
167
|
+
onFocus: () => void 0,
|
|
168
|
+
onBlur: () => void 0,
|
|
421
169
|
tabIndex: -1
|
|
422
170
|
};
|
|
423
|
-
|
|
171
|
+
const keyCodes = {
|
|
424
172
|
enter: 13,
|
|
425
173
|
space: 32
|
|
426
174
|
};
|
|
427
|
-
|
|
175
|
+
const startState = {
|
|
428
176
|
hovered: false,
|
|
429
177
|
focused: false,
|
|
430
178
|
pressed: false,
|
|
@@ -504,149 +252,126 @@ var startState = {
|
|
|
504
252
|
* The react-router aware version is returned if `router` is a react-router-dom
|
|
505
253
|
* router, `skipClientNav` is not `true`, and `href` is an internal URL.
|
|
506
254
|
*
|
|
507
|
-
* The `router` can be accessed via
|
|
508
|
-
* rendered as a descendant of a BrowserRouter.
|
|
255
|
+
* The `router` can be accessed via __RouterContext (imported from 'react-router')
|
|
256
|
+
* from a component rendered as a descendant of a BrowserRouter.
|
|
509
257
|
* See https://reacttraining.com/react-router/web/guides/basic-components.
|
|
510
258
|
*/
|
|
511
259
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
// If new props are disabled, reset the hovered/focused/pressed states
|
|
521
|
-
if (props.disabled) {
|
|
522
|
-
return startState;
|
|
523
|
-
} else {
|
|
524
|
-
// Cannot return undefined
|
|
525
|
-
return null;
|
|
526
|
-
}
|
|
260
|
+
class ClickableBehavior extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
261
|
+
static getDerivedStateFromProps(props, state) {
|
|
262
|
+
// If new props are disabled, reset the hovered/focused/pressed states
|
|
263
|
+
if (props.disabled) {
|
|
264
|
+
return startState;
|
|
265
|
+
} else {
|
|
266
|
+
// Cannot return undefined
|
|
267
|
+
return null;
|
|
527
268
|
}
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
function ClickableBehavior(props) {
|
|
531
|
-
var _this;
|
|
532
|
-
|
|
533
|
-
_classCallCheck(this, ClickableBehavior);
|
|
534
|
-
|
|
535
|
-
_this = _super.call(this, props);
|
|
536
|
-
|
|
537
|
-
clickable_behavior_defineProperty(_assertThisInitialized(_this), "waitingForClick", void 0);
|
|
538
|
-
|
|
539
|
-
clickable_behavior_defineProperty(_assertThisInitialized(_this), "enterClick", void 0);
|
|
269
|
+
}
|
|
540
270
|
|
|
541
|
-
|
|
271
|
+
constructor(props) {
|
|
272
|
+
super(props);
|
|
542
273
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
_this$props$safeWithN = _this$props.safeWithNav,
|
|
550
|
-
safeWithNav = _this$props$safeWithN === void 0 ? undefined : _this$props$safeWithN;
|
|
274
|
+
this.handleClick = e => {
|
|
275
|
+
const {
|
|
276
|
+
onClick = undefined,
|
|
277
|
+
beforeNav = undefined,
|
|
278
|
+
safeWithNav = undefined
|
|
279
|
+
} = this.props;
|
|
551
280
|
|
|
552
|
-
if (
|
|
281
|
+
if (this.enterClick) {
|
|
553
282
|
return;
|
|
554
283
|
}
|
|
555
284
|
|
|
556
285
|
if (onClick || beforeNav || safeWithNav) {
|
|
557
|
-
|
|
286
|
+
this.waitingForClick = false;
|
|
558
287
|
}
|
|
559
288
|
|
|
560
|
-
|
|
561
|
-
}
|
|
289
|
+
this.runCallbackAndMaybeNavigate(e);
|
|
290
|
+
};
|
|
562
291
|
|
|
563
|
-
|
|
292
|
+
this.handleMouseEnter = e => {
|
|
564
293
|
// When the left button is pressed already, we want it to be pressed
|
|
565
294
|
if (e.buttons === 1) {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
_this.setState({
|
|
295
|
+
this.dragging = true;
|
|
296
|
+
this.setState({
|
|
569
297
|
pressed: true
|
|
570
298
|
});
|
|
571
|
-
} else if (!
|
|
572
|
-
|
|
299
|
+
} else if (!this.waitingForClick) {
|
|
300
|
+
this.setState({
|
|
573
301
|
hovered: true
|
|
574
302
|
});
|
|
575
303
|
}
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
clickable_behavior_defineProperty(_assertThisInitialized(_this), "handleMouseLeave", function () {
|
|
579
|
-
if (!_this.waitingForClick) {
|
|
580
|
-
_this.dragging = false;
|
|
304
|
+
};
|
|
581
305
|
|
|
582
|
-
|
|
306
|
+
this.handleMouseLeave = () => {
|
|
307
|
+
if (!this.waitingForClick) {
|
|
308
|
+
this.dragging = false;
|
|
309
|
+
this.setState({
|
|
583
310
|
hovered: false,
|
|
584
311
|
pressed: false,
|
|
585
312
|
focused: false
|
|
586
313
|
});
|
|
587
314
|
}
|
|
588
|
-
}
|
|
315
|
+
};
|
|
589
316
|
|
|
590
|
-
|
|
591
|
-
|
|
317
|
+
this.handleMouseDown = () => {
|
|
318
|
+
this.setState({
|
|
592
319
|
pressed: true
|
|
593
320
|
});
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
clickable_behavior_defineProperty(_assertThisInitialized(_this), "handleMouseUp", function (e) {
|
|
597
|
-
if (_this.dragging) {
|
|
598
|
-
_this.dragging = false;
|
|
321
|
+
};
|
|
599
322
|
|
|
600
|
-
|
|
323
|
+
this.handleMouseUp = e => {
|
|
324
|
+
if (this.dragging) {
|
|
325
|
+
this.dragging = false;
|
|
326
|
+
this.handleClick(e);
|
|
601
327
|
}
|
|
602
328
|
|
|
603
|
-
|
|
329
|
+
this.setState({
|
|
604
330
|
pressed: false,
|
|
605
331
|
focused: false
|
|
606
332
|
});
|
|
607
|
-
}
|
|
333
|
+
};
|
|
608
334
|
|
|
609
|
-
|
|
610
|
-
|
|
335
|
+
this.handleDragStart = e => {
|
|
336
|
+
this.dragging = true;
|
|
611
337
|
e.preventDefault();
|
|
612
|
-
}
|
|
338
|
+
};
|
|
613
339
|
|
|
614
|
-
|
|
615
|
-
|
|
340
|
+
this.handleTouchStart = () => {
|
|
341
|
+
this.setState({
|
|
616
342
|
pressed: true
|
|
617
343
|
});
|
|
618
|
-
}
|
|
344
|
+
};
|
|
619
345
|
|
|
620
|
-
|
|
621
|
-
|
|
346
|
+
this.handleTouchEnd = () => {
|
|
347
|
+
this.setState({
|
|
622
348
|
pressed: false
|
|
623
349
|
});
|
|
350
|
+
this.waitingForClick = true;
|
|
351
|
+
};
|
|
624
352
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
clickable_behavior_defineProperty(_assertThisInitialized(_this), "handleTouchCancel", function () {
|
|
629
|
-
_this.setState({
|
|
353
|
+
this.handleTouchCancel = () => {
|
|
354
|
+
this.setState({
|
|
630
355
|
pressed: false
|
|
631
356
|
});
|
|
357
|
+
this.waitingForClick = true;
|
|
358
|
+
};
|
|
632
359
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
onKeyDown = _this$props2.onKeyDown,
|
|
639
|
-
role = _this$props2.role;
|
|
360
|
+
this.handleKeyDown = e => {
|
|
361
|
+
const {
|
|
362
|
+
onKeyDown,
|
|
363
|
+
role
|
|
364
|
+
} = this.props;
|
|
640
365
|
|
|
641
366
|
if (onKeyDown) {
|
|
642
367
|
onKeyDown(e);
|
|
643
368
|
}
|
|
644
369
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
370
|
+
const keyCode = e.which || e.keyCode;
|
|
371
|
+
const {
|
|
372
|
+
triggerOnEnter,
|
|
373
|
+
triggerOnSpace
|
|
374
|
+
} = getAppropriateTriggersForRole(role);
|
|
650
375
|
|
|
651
376
|
if (triggerOnEnter && keyCode === keyCodes.enter || triggerOnSpace && keyCode === keyCodes.space) {
|
|
652
377
|
// This prevents space from scrolling down. It also prevents the
|
|
@@ -654,112 +379,116 @@ var clickable_behavior_ClickableBehavior = /*#__PURE__*/function (_React$Compone
|
|
|
654
379
|
// call the supplied onClick and handle potential navigation in
|
|
655
380
|
// handleKeyUp instead.
|
|
656
381
|
e.preventDefault();
|
|
657
|
-
|
|
658
|
-
_this.setState({
|
|
382
|
+
this.setState({
|
|
659
383
|
pressed: true
|
|
660
384
|
});
|
|
661
385
|
} else if (!triggerOnEnter && keyCode === keyCodes.enter) {
|
|
662
386
|
// If the component isn't supposed to trigger on enter, we have to
|
|
663
387
|
// keep track of the enter keydown to negate the onClick callback
|
|
664
|
-
|
|
388
|
+
this.enterClick = true;
|
|
665
389
|
}
|
|
666
|
-
}
|
|
390
|
+
};
|
|
667
391
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
392
|
+
this.handleKeyUp = e => {
|
|
393
|
+
const {
|
|
394
|
+
onKeyUp,
|
|
395
|
+
role
|
|
396
|
+
} = this.props;
|
|
672
397
|
|
|
673
398
|
if (onKeyUp) {
|
|
674
399
|
onKeyUp(e);
|
|
675
400
|
}
|
|
676
401
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
402
|
+
const keyCode = e.which || e.keyCode;
|
|
403
|
+
const {
|
|
404
|
+
triggerOnEnter,
|
|
405
|
+
triggerOnSpace
|
|
406
|
+
} = getAppropriateTriggersForRole(role);
|
|
682
407
|
|
|
683
408
|
if (triggerOnEnter && keyCode === keyCodes.enter || triggerOnSpace && keyCode === keyCodes.space) {
|
|
684
|
-
|
|
409
|
+
this.setState({
|
|
685
410
|
pressed: false,
|
|
686
411
|
focused: true
|
|
687
412
|
});
|
|
688
|
-
|
|
689
|
-
_this.runCallbackAndMaybeNavigate(e);
|
|
413
|
+
this.runCallbackAndMaybeNavigate(e);
|
|
690
414
|
} else if (!triggerOnEnter && keyCode === keyCodes.enter) {
|
|
691
|
-
|
|
415
|
+
this.enterClick = false;
|
|
692
416
|
}
|
|
693
|
-
}
|
|
417
|
+
};
|
|
694
418
|
|
|
695
|
-
|
|
696
|
-
|
|
419
|
+
this.handleFocus = e => {
|
|
420
|
+
this.setState({
|
|
697
421
|
focused: true
|
|
698
422
|
});
|
|
699
|
-
}
|
|
423
|
+
};
|
|
700
424
|
|
|
701
|
-
|
|
702
|
-
|
|
425
|
+
this.handleBlur = e => {
|
|
426
|
+
this.setState({
|
|
703
427
|
focused: false,
|
|
704
428
|
pressed: false
|
|
705
429
|
});
|
|
706
|
-
}
|
|
430
|
+
};
|
|
707
431
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
return _this;
|
|
432
|
+
this.state = startState;
|
|
433
|
+
this.waitingForClick = false;
|
|
434
|
+
this.enterClick = false;
|
|
435
|
+
this.dragging = false;
|
|
713
436
|
}
|
|
714
437
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
window.location.assign(href); // We don't bother clearing the waiting state, the full page
|
|
739
|
-
// load navigation will do that for us by loading a new page.
|
|
740
|
-
}
|
|
438
|
+
navigateOrReset(shouldNavigate) {
|
|
439
|
+
if (shouldNavigate) {
|
|
440
|
+
const {
|
|
441
|
+
history,
|
|
442
|
+
href,
|
|
443
|
+
skipClientNav,
|
|
444
|
+
target = undefined
|
|
445
|
+
} = this.props;
|
|
446
|
+
|
|
447
|
+
if (href) {
|
|
448
|
+
if (target === "_blank") {
|
|
449
|
+
window.open(href, "_blank");
|
|
450
|
+
this.setState({
|
|
451
|
+
waiting: false
|
|
452
|
+
});
|
|
453
|
+
} else if (history && !skipClientNav) {
|
|
454
|
+
history.push(href);
|
|
455
|
+
this.setState({
|
|
456
|
+
waiting: false
|
|
457
|
+
});
|
|
458
|
+
} else {
|
|
459
|
+
window.location.assign(href); // We don't bother clearing the waiting state, the full page
|
|
460
|
+
// load navigation will do that for us by loading a new page.
|
|
741
461
|
}
|
|
742
|
-
}
|
|
462
|
+
}
|
|
463
|
+
} else {
|
|
464
|
+
this.setState({
|
|
465
|
+
waiting: false
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
handleSafeWithNav(safeWithNav, shouldNavigate) {
|
|
471
|
+
const {
|
|
472
|
+
skipClientNav,
|
|
473
|
+
history
|
|
474
|
+
} = this.props;
|
|
475
|
+
|
|
476
|
+
if (history && !skipClientNav || this.props.target === "_blank") {
|
|
477
|
+
// client-side nav
|
|
478
|
+
safeWithNav();
|
|
479
|
+
this.navigateOrReset(shouldNavigate);
|
|
480
|
+
return Promise.resolve();
|
|
481
|
+
} else {
|
|
482
|
+
if (!this.state.waiting) {
|
|
483
|
+
// We only show the spinner for safeWithNav when doing
|
|
484
|
+
// a full page load navigation since since the spinner is
|
|
485
|
+
// indicating that we're waiting for navigation to occur.
|
|
743
486
|
this.setState({
|
|
744
|
-
waiting:
|
|
487
|
+
waiting: true
|
|
745
488
|
});
|
|
746
489
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
key: "handleSafeWithNav",
|
|
750
|
-
value: function handleSafeWithNav(safeWithNav, shouldNavigate) {
|
|
751
|
-
var _this2 = this;
|
|
752
|
-
|
|
753
|
-
var _this$props5 = this.props,
|
|
754
|
-
skipClientNav = _this$props5.skipClientNav,
|
|
755
|
-
history = _this$props5.history;
|
|
756
|
-
|
|
757
|
-
if (history && !skipClientNav || this.props.target === "_blank") {
|
|
758
|
-
// client-side nav
|
|
759
|
-
safeWithNav();
|
|
760
|
-
this.navigateOrReset(shouldNavigate);
|
|
761
|
-
return Promise.resolve();
|
|
762
|
-
} else {
|
|
490
|
+
|
|
491
|
+
return safeWithNav().then(() => {
|
|
763
492
|
if (!this.state.waiting) {
|
|
764
493
|
// We only show the spinner for safeWithNav when doing
|
|
765
494
|
// a full page load navigation since since the spinner is
|
|
@@ -769,166 +498,145 @@ var clickable_behavior_ClickableBehavior = /*#__PURE__*/function (_React$Compone
|
|
|
769
498
|
});
|
|
770
499
|
}
|
|
771
500
|
|
|
772
|
-
return
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
return;
|
|
783
|
-
}).catch(function (error) {// We ignore the error here so that we always
|
|
784
|
-
// navigate when using safeWithNav regardless of
|
|
785
|
-
// whether we're doing a client-side nav or not.
|
|
786
|
-
}).finally(function () {
|
|
787
|
-
_this2.navigateOrReset(shouldNavigate);
|
|
788
|
-
});
|
|
789
|
-
}
|
|
501
|
+
return;
|
|
502
|
+
}).catch(error => {// We ignore the error here so that we always
|
|
503
|
+
// navigate when using safeWithNav regardless of
|
|
504
|
+
// whether we're doing a client-side nav or not.
|
|
505
|
+
}).finally(() => {
|
|
506
|
+
this.navigateOrReset(shouldNavigate);
|
|
507
|
+
});
|
|
790
508
|
}
|
|
791
|
-
}
|
|
792
|
-
key: "runCallbackAndMaybeNavigate",
|
|
793
|
-
value: function runCallbackAndMaybeNavigate(e) {
|
|
794
|
-
var _this3 = this;
|
|
795
|
-
|
|
796
|
-
var _this$props6 = this.props,
|
|
797
|
-
_this$props6$onClick = _this$props6.onClick,
|
|
798
|
-
onClick = _this$props6$onClick === void 0 ? undefined : _this$props6$onClick,
|
|
799
|
-
_this$props6$beforeNa = _this$props6.beforeNav,
|
|
800
|
-
beforeNav = _this$props6$beforeNa === void 0 ? undefined : _this$props6$beforeNa,
|
|
801
|
-
_this$props6$safeWith = _this$props6.safeWithNav,
|
|
802
|
-
safeWithNav = _this$props6$safeWith === void 0 ? undefined : _this$props6$safeWith,
|
|
803
|
-
href = _this$props6.href,
|
|
804
|
-
type = _this$props6.type;
|
|
805
|
-
var shouldNavigate = true;
|
|
806
|
-
var canSubmit = true;
|
|
807
|
-
|
|
808
|
-
if (onClick) {
|
|
809
|
-
onClick(e);
|
|
810
|
-
} // If onClick() has called e.preventDefault() then we shouldn't
|
|
811
|
-
// navigate.
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
if (e.defaultPrevented) {
|
|
815
|
-
shouldNavigate = false;
|
|
816
|
-
canSubmit = false;
|
|
817
|
-
}
|
|
509
|
+
}
|
|
818
510
|
|
|
819
|
-
|
|
511
|
+
runCallbackAndMaybeNavigate(e) {
|
|
512
|
+
const {
|
|
513
|
+
onClick = undefined,
|
|
514
|
+
beforeNav = undefined,
|
|
515
|
+
safeWithNav = undefined,
|
|
516
|
+
href,
|
|
517
|
+
type
|
|
518
|
+
} = this.props;
|
|
519
|
+
let shouldNavigate = true;
|
|
520
|
+
let canSubmit = true;
|
|
521
|
+
|
|
522
|
+
if (onClick) {
|
|
523
|
+
onClick(e);
|
|
524
|
+
} // If onClick() has called e.preventDefault() then we shouldn't
|
|
525
|
+
// navigate.
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
if (e.defaultPrevented) {
|
|
529
|
+
shouldNavigate = false;
|
|
530
|
+
canSubmit = false;
|
|
531
|
+
}
|
|
820
532
|
|
|
821
|
-
|
|
822
|
-
var target = e.currentTarget;
|
|
823
|
-
|
|
824
|
-
while (target) {
|
|
825
|
-
if (target instanceof window.HTMLFormElement) {
|
|
826
|
-
// This event must be marked as cancelable otherwise calling
|
|
827
|
-
// e.preventDefault() on it won't do anything in Firefox.
|
|
828
|
-
// Chrome and Safari allow calling e.preventDefault() on
|
|
829
|
-
// non-cancelable events, but really they shouldn't.
|
|
830
|
-
var event = new window.Event("submit", {
|
|
831
|
-
cancelable: true
|
|
832
|
-
});
|
|
833
|
-
target.dispatchEvent(event);
|
|
834
|
-
break;
|
|
835
|
-
} // All events should be typed as SyntheticEvent<HTMLElement>.
|
|
836
|
-
// Updating all of the places will take some time so I'll do
|
|
837
|
-
// this later
|
|
838
|
-
// $FlowFixMe[prop-missing]
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
target = target.parentElement;
|
|
842
|
-
}
|
|
843
|
-
}
|
|
533
|
+
e.preventDefault();
|
|
844
534
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
535
|
+
if (!href && type === "submit" && canSubmit) {
|
|
536
|
+
let target = e.currentTarget;
|
|
537
|
+
|
|
538
|
+
while (target) {
|
|
539
|
+
if (target instanceof window.HTMLFormElement) {
|
|
540
|
+
// This event must be marked as cancelable otherwise calling
|
|
541
|
+
// e.preventDefault() on it won't do anything in Firefox.
|
|
542
|
+
// Chrome and Safari allow calling e.preventDefault() on
|
|
543
|
+
// non-cancelable events, but really they shouldn't.
|
|
544
|
+
const event = new window.Event("submit", {
|
|
545
|
+
cancelable: true
|
|
546
|
+
});
|
|
547
|
+
target.dispatchEvent(event);
|
|
548
|
+
break;
|
|
549
|
+
} // All events should be typed as SyntheticEvent<HTMLElement>.
|
|
550
|
+
// Updating all of the places will take some time so I'll do
|
|
551
|
+
// this later
|
|
552
|
+
// $FlowFixMe[prop-missing]
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
target = target.parentElement;
|
|
860
556
|
}
|
|
861
557
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
onBlur: this.handleBlur,
|
|
879
|
-
// We set tabIndex to 0 so that users can tab to clickable
|
|
880
|
-
// things that aren't buttons or anchors.
|
|
881
|
-
tabIndex: 0
|
|
882
|
-
}; // When the link is set to open in a new window, we want to set some
|
|
883
|
-
// `rel` attributes. This is to ensure that the links we're sending folks
|
|
884
|
-
// to can't hijack the existing page. These defaults can be overriden
|
|
885
|
-
// by passing in a different value for the `rel` prop.
|
|
886
|
-
// More info: https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/
|
|
887
|
-
|
|
888
|
-
childrenProps.rel = this.props.rel || (this.props.target === "_blank" ? "noopener noreferrer" : undefined);
|
|
889
|
-
var children = this.props.children;
|
|
890
|
-
return children && children(this.state, childrenProps);
|
|
558
|
+
|
|
559
|
+
if (beforeNav) {
|
|
560
|
+
this.setState({
|
|
561
|
+
waiting: true
|
|
562
|
+
});
|
|
563
|
+
beforeNav().then(() => {
|
|
564
|
+
if (safeWithNav) {
|
|
565
|
+
return this.handleSafeWithNav(safeWithNav, shouldNavigate);
|
|
566
|
+
} else {
|
|
567
|
+
return this.navigateOrReset(shouldNavigate);
|
|
568
|
+
}
|
|
569
|
+
}).catch(() => {});
|
|
570
|
+
} else if (safeWithNav) {
|
|
571
|
+
return this.handleSafeWithNav(safeWithNav, shouldNavigate);
|
|
572
|
+
} else {
|
|
573
|
+
this.navigateOrReset(shouldNavigate);
|
|
891
574
|
}
|
|
892
|
-
}
|
|
575
|
+
}
|
|
893
576
|
|
|
894
|
-
|
|
895
|
-
|
|
577
|
+
render() {
|
|
578
|
+
const childrenProps = this.props.disabled ? disabledHandlers : {
|
|
579
|
+
onClick: this.handleClick,
|
|
580
|
+
onMouseEnter: this.handleMouseEnter,
|
|
581
|
+
onMouseLeave: this.handleMouseLeave,
|
|
582
|
+
onMouseDown: this.handleMouseDown,
|
|
583
|
+
onMouseUp: this.handleMouseUp,
|
|
584
|
+
onDragStart: this.handleDragStart,
|
|
585
|
+
onTouchStart: this.handleTouchStart,
|
|
586
|
+
onTouchEnd: this.handleTouchEnd,
|
|
587
|
+
onTouchCancel: this.handleTouchCancel,
|
|
588
|
+
onKeyDown: this.handleKeyDown,
|
|
589
|
+
onKeyUp: this.handleKeyUp,
|
|
590
|
+
onFocus: this.handleFocus,
|
|
591
|
+
onBlur: this.handleBlur,
|
|
592
|
+
// We set tabIndex to 0 so that users can tab to clickable
|
|
593
|
+
// things that aren't buttons or anchors.
|
|
594
|
+
tabIndex: 0
|
|
595
|
+
}; // When the link is set to open in a new window, we want to set some
|
|
596
|
+
// `rel` attributes. This is to ensure that the links we're sending folks
|
|
597
|
+
// to can't hijack the existing page. These defaults can be overriden
|
|
598
|
+
// by passing in a different value for the `rel` prop.
|
|
599
|
+
// More info: https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/
|
|
600
|
+
|
|
601
|
+
childrenProps.rel = this.props.rel || (this.props.target === "_blank" ? "noopener noreferrer" : undefined);
|
|
602
|
+
const {
|
|
603
|
+
children
|
|
604
|
+
} = this.props;
|
|
605
|
+
return children && children(this.state, childrenProps);
|
|
606
|
+
}
|
|
896
607
|
|
|
897
|
-
|
|
608
|
+
}
|
|
609
|
+
ClickableBehavior.defaultProps = {
|
|
898
610
|
disabled: false
|
|
899
|
-
}
|
|
900
|
-
|
|
611
|
+
};
|
|
901
612
|
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
* - false for hrefs staring with http://, https://, //.
|
|
906
|
-
* - false for '#', 'javascript:...', 'mailto:...', 'tel:...', etc.
|
|
907
|
-
* - true for all other values, e.g. /foo/bar
|
|
908
|
-
*/
|
|
909
|
-
var isClientSideUrl = function isClientSideUrl(href) {
|
|
910
|
-
if (typeof href !== "string") {
|
|
911
|
-
return false;
|
|
912
|
-
}
|
|
613
|
+
/***/ }),
|
|
614
|
+
/* 3 */
|
|
615
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
913
616
|
|
|
914
|
-
|
|
915
|
-
};
|
|
916
|
-
|
|
617
|
+
"use strict";
|
|
618
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getClickableBehavior; });
|
|
619
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
620
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
621
|
+
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
622
|
+
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
623
|
+
/* harmony import */ var _components_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
|
|
624
|
+
/* harmony import */ var _is_client_side_url_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1);
|
|
917
625
|
/**
|
|
918
626
|
* Returns either the default ClickableBehavior or a react-router aware version.
|
|
919
627
|
*
|
|
920
628
|
* The react-router aware version is returned if `router` is a react-router-dom
|
|
921
629
|
* router, `skipClientNav` is not `true`, and `href` is an internal URL.
|
|
922
630
|
*
|
|
923
|
-
* The `router` can be accessed via
|
|
924
|
-
* as a descendant of a BrowserRouter.
|
|
631
|
+
* The `router` can be accessed via __RouterContext (imported from 'react-router')
|
|
632
|
+
* from a component rendered as a descendant of a BrowserRouter.
|
|
925
633
|
* See https://reacttraining.com/react-router/web/guides/basic-components.
|
|
926
634
|
*/
|
|
927
635
|
|
|
928
636
|
|
|
929
637
|
|
|
930
638
|
|
|
931
|
-
|
|
639
|
+
const ClickableBehaviorWithRouter = Object(react_router_dom__WEBPACK_IMPORTED_MODULE_1__["withRouter"])(_components_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"]);
|
|
932
640
|
function getClickableBehavior(
|
|
933
641
|
/**
|
|
934
642
|
* The URL to navigate to.
|
|
@@ -942,7 +650,7 @@ skipClientNav,
|
|
|
942
650
|
* router object added to the React context object by react-router-dom.
|
|
943
651
|
*/
|
|
944
652
|
router) {
|
|
945
|
-
if (router && skipClientNav !== true && href && isClientSideUrl(href)) {
|
|
653
|
+
if (router && skipClientNav !== true && href && Object(_is_client_side_url_js__WEBPACK_IMPORTED_MODULE_3__[/* isClientSideUrl */ "a"])(href)) {
|
|
946
654
|
// We cast to `any` here since the type of ClickableBehaviorWithRouter
|
|
947
655
|
// is slightly different from the return type of this function.
|
|
948
656
|
// TODO(WB-1037): Always return the wrapped version once all routes have
|
|
@@ -950,42 +658,179 @@ router) {
|
|
|
950
658
|
return ClickableBehaviorWithRouter;
|
|
951
659
|
}
|
|
952
660
|
|
|
953
|
-
return
|
|
661
|
+
return _components_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"];
|
|
954
662
|
}
|
|
955
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-clickable/src/components/clickable.js
|
|
956
|
-
function clickable_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { clickable_typeof = function _typeof(obj) { return typeof obj; }; } else { clickable_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return clickable_typeof(obj); }
|
|
957
663
|
|
|
958
|
-
|
|
664
|
+
/***/ }),
|
|
665
|
+
/* 4 */
|
|
666
|
+
/***/ (function(module, exports) {
|
|
959
667
|
|
|
960
|
-
|
|
668
|
+
module.exports = require("react-router-dom");
|
|
961
669
|
|
|
962
|
-
|
|
670
|
+
/***/ }),
|
|
671
|
+
/* 5 */
|
|
672
|
+
/***/ (function(module, exports) {
|
|
963
673
|
|
|
964
|
-
|
|
674
|
+
module.exports = require("@khanacademy/wonder-blocks-core");
|
|
965
675
|
|
|
966
|
-
|
|
676
|
+
/***/ }),
|
|
677
|
+
/* 6 */
|
|
678
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
679
|
+
|
|
680
|
+
"use strict";
|
|
681
|
+
/* unused harmony export SemanticColor */
|
|
682
|
+
/* unused harmony export fade */
|
|
683
|
+
/* unused harmony export mix */
|
|
684
|
+
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
|
|
685
|
+
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* A color manipulation library useful for dynamically
|
|
689
|
+
* mixing colors together.
|
|
690
|
+
*/
|
|
691
|
+
|
|
692
|
+
const color6Regexp = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i;
|
|
693
|
+
const color3Regexp = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i;
|
|
694
|
+
const rgbaRegexp = /^rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\s*\)$/i; // Parse a color in #abcdef, rgb(...), or rgba(...) form into an object
|
|
695
|
+
// with r,g,b,a keys.
|
|
696
|
+
|
|
697
|
+
const parse = color => {
|
|
698
|
+
if (typeof color !== "string") {
|
|
699
|
+
throw new Error(`Failed to parse color: ${color}`);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
const color3Match = color.match(color3Regexp);
|
|
703
|
+
|
|
704
|
+
if (color3Match) {
|
|
705
|
+
return {
|
|
706
|
+
r: parseInt(`${color3Match[1]}${color3Match[1]}`, 16),
|
|
707
|
+
g: parseInt(`${color3Match[2]}${color3Match[2]}`, 16),
|
|
708
|
+
b: parseInt(`${color3Match[3]}${color3Match[3]}`, 16),
|
|
709
|
+
a: 1
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
const color6Match = color.match(color6Regexp);
|
|
714
|
+
|
|
715
|
+
if (color6Match) {
|
|
716
|
+
return {
|
|
717
|
+
r: parseInt(color6Match[1], 16),
|
|
718
|
+
g: parseInt(color6Match[2], 16),
|
|
719
|
+
b: parseInt(color6Match[3], 16),
|
|
720
|
+
a: 1
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
const rgbaMatch = color.match(rgbaRegexp);
|
|
725
|
+
|
|
726
|
+
if (rgbaMatch) {
|
|
727
|
+
return {
|
|
728
|
+
r: parseFloat(rgbaMatch[1]),
|
|
729
|
+
g: parseFloat(rgbaMatch[2]),
|
|
730
|
+
b: parseFloat(rgbaMatch[3]),
|
|
731
|
+
a: rgbaMatch[4] ? parseFloat(rgbaMatch[4]) : 1
|
|
732
|
+
};
|
|
733
|
+
}
|
|
967
734
|
|
|
968
|
-
|
|
735
|
+
throw new Error(`Failed to parse color: ${color}`);
|
|
736
|
+
}; // Stringify the color in an `rgba()` or `#abcdef` format.
|
|
969
737
|
|
|
970
|
-
function clickable_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
971
738
|
|
|
972
|
-
|
|
739
|
+
const format = color => {
|
|
740
|
+
const r = Math.round(color.r);
|
|
741
|
+
const g = Math.round(color.g);
|
|
742
|
+
const b = Math.round(color.b);
|
|
973
743
|
|
|
974
|
-
|
|
744
|
+
if (color.a === 1) {
|
|
745
|
+
const _s = c => {
|
|
746
|
+
const asString = c.toString(16);
|
|
747
|
+
return asString.length === 1 ? asString + asString : asString;
|
|
748
|
+
};
|
|
975
749
|
|
|
976
|
-
|
|
750
|
+
return `#${_s(r)}${_s(g)}${_s(b)}`;
|
|
751
|
+
} else {
|
|
752
|
+
return `rgba(${r},${g},${b},${color.a.toFixed(2)})`;
|
|
753
|
+
}
|
|
754
|
+
}; // Adjust the alpha value of a color.
|
|
977
755
|
|
|
978
|
-
function clickable_createSuper(Derived) { var hasNativeReflectConstruct = clickable_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = clickable_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = clickable_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return clickable_possibleConstructorReturn(this, result); }; }
|
|
979
756
|
|
|
980
|
-
|
|
757
|
+
const fade = (color, percentage) => {
|
|
758
|
+
if (percentage < 0 || percentage > 1) {
|
|
759
|
+
throw new Error("Percentage must be between 0 and 1");
|
|
760
|
+
}
|
|
981
761
|
|
|
982
|
-
|
|
762
|
+
const components = parse(color);
|
|
763
|
+
return format(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, components, {
|
|
764
|
+
a: components.a * percentage
|
|
765
|
+
}));
|
|
766
|
+
}; // Mix a color into a background color, using the alpha channel of the base
|
|
767
|
+
// color to determine the linear blend.
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
const mix = (color, background) => {
|
|
771
|
+
const colorObj = parse(color);
|
|
772
|
+
const bgObj = parse(background);
|
|
773
|
+
return format({
|
|
774
|
+
r: colorObj.r * colorObj.a + bgObj.r * (1 - colorObj.a),
|
|
775
|
+
g: colorObj.g * colorObj.a + bgObj.g * (1 - colorObj.a),
|
|
776
|
+
b: colorObj.b * colorObj.a + bgObj.b * (1 - colorObj.a),
|
|
777
|
+
a: bgObj.a
|
|
778
|
+
});
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
const offBlack = "#21242c";
|
|
782
|
+
const white = "#ffffff";
|
|
783
|
+
const Color = {
|
|
784
|
+
// Product
|
|
785
|
+
blue: "#1865f2",
|
|
786
|
+
purple: "#9059ff",
|
|
787
|
+
green: "#00a60e",
|
|
788
|
+
gold: "#ffb100",
|
|
789
|
+
red: "#d92916",
|
|
790
|
+
// Neutral
|
|
791
|
+
offBlack,
|
|
792
|
+
offBlack64: fade(offBlack, 0.64),
|
|
793
|
+
offBlack50: fade(offBlack, 0.5),
|
|
794
|
+
offBlack32: fade(offBlack, 0.32),
|
|
795
|
+
offBlack16: fade(offBlack, 0.16),
|
|
796
|
+
offBlack8: fade(offBlack, 0.08),
|
|
797
|
+
offWhite: "#f7f8fa",
|
|
798
|
+
white,
|
|
799
|
+
white64: fade(white, 0.64),
|
|
800
|
+
white50: fade(white, 0.5),
|
|
801
|
+
// Brand
|
|
802
|
+
darkBlue: "#0a2a66",
|
|
803
|
+
teal: "#14bf96",
|
|
804
|
+
lightBlue: "#37c5fd",
|
|
805
|
+
pink: "#fa50ae"
|
|
806
|
+
};
|
|
807
|
+
const SemanticColor = {
|
|
808
|
+
controlDefault: Color.blue,
|
|
809
|
+
controlDestructive: Color.red
|
|
810
|
+
};
|
|
811
|
+
/* harmony default export */ __webpack_exports__["a"] = (Color);
|
|
983
812
|
|
|
984
|
-
function clickable_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
985
813
|
|
|
986
|
-
|
|
814
|
+
/***/ }),
|
|
815
|
+
/* 7 */
|
|
816
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
987
817
|
|
|
988
|
-
|
|
818
|
+
"use strict";
|
|
819
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Clickable; });
|
|
820
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
821
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
822
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
|
|
823
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
824
|
+
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
|
825
|
+
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_2__);
|
|
826
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9);
|
|
827
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_router__WEBPACK_IMPORTED_MODULE_3__);
|
|
828
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5);
|
|
829
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__);
|
|
830
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6);
|
|
831
|
+
/* harmony import */ var _util_get_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3);
|
|
832
|
+
/* harmony import */ var _util_is_client_side_url_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1);
|
|
833
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
989
834
|
|
|
990
835
|
|
|
991
836
|
|
|
@@ -995,9 +840,9 @@ function clickable_defineProperty(obj, key, value) { if (key in obj) { Object.de
|
|
|
995
840
|
|
|
996
841
|
|
|
997
842
|
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
843
|
+
const StyledAnchor = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__["addStyle"])("a");
|
|
844
|
+
const StyledButton = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__["addStyle"])("button");
|
|
845
|
+
const StyledLink = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__["addStyle"])(react_router_dom__WEBPACK_IMPORTED_MODULE_2__["Link"]);
|
|
1001
846
|
/**
|
|
1002
847
|
* A component to turn any custom component into a clickable one.
|
|
1003
848
|
*
|
|
@@ -1023,132 +868,102 @@ var StyledLink = Object(wonder_blocks_core_["addStyle"])(external_react_router_d
|
|
|
1023
868
|
* ```
|
|
1024
869
|
*/
|
|
1025
870
|
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
var _super = clickable_createSuper(Clickable);
|
|
871
|
+
class Clickable extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
872
|
+
constructor(...args) {
|
|
873
|
+
super(...args);
|
|
1030
874
|
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
clickable_classCallCheck(this, Clickable);
|
|
1035
|
-
|
|
1036
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1037
|
-
args[_key] = arguments[_key];
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
1041
|
-
|
|
1042
|
-
clickable_defineProperty(clickable_assertThisInitialized(_this), "getCorrectTag", function (clickableState, commonProps) {
|
|
1043
|
-
var activeHref = _this.props.href && !_this.props.disabled;
|
|
1044
|
-
var useClient = _this.context.router && !_this.props.skipClientNav && isClientSideUrl(_this.props.href || ""); // NOTE: checking this.props.href here is redundant, but flow
|
|
875
|
+
this.getCorrectTag = (clickableState, router, commonProps) => {
|
|
876
|
+
const activeHref = this.props.href && !this.props.disabled;
|
|
877
|
+
const useClient = router && !this.props.skipClientNav && Object(_util_is_client_side_url_js__WEBPACK_IMPORTED_MODULE_7__[/* isClientSideUrl */ "a"])(this.props.href || ""); // NOTE: checking this.props.href here is redundant, but flow
|
|
1045
878
|
// needs it to refine this.props.href to a string.
|
|
1046
879
|
|
|
1047
|
-
if (activeHref && useClient &&
|
|
1048
|
-
return /*#__PURE__*/
|
|
1049
|
-
to:
|
|
1050
|
-
role:
|
|
1051
|
-
target:
|
|
1052
|
-
"aria-disabled":
|
|
1053
|
-
}),
|
|
880
|
+
if (activeHref && useClient && this.props.href) {
|
|
881
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](StyledLink, _extends({}, commonProps, {
|
|
882
|
+
to: this.props.href,
|
|
883
|
+
role: this.props.role,
|
|
884
|
+
target: this.props.target || undefined,
|
|
885
|
+
"aria-disabled": this.props.disabled ? "true" : undefined
|
|
886
|
+
}), this.props.children(clickableState));
|
|
1054
887
|
} else if (activeHref && !useClient) {
|
|
1055
|
-
return /*#__PURE__*/
|
|
1056
|
-
href:
|
|
1057
|
-
role:
|
|
1058
|
-
target:
|
|
1059
|
-
"aria-disabled":
|
|
1060
|
-
}),
|
|
888
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](StyledAnchor, _extends({}, commonProps, {
|
|
889
|
+
href: this.props.href,
|
|
890
|
+
role: this.props.role,
|
|
891
|
+
target: this.props.target || undefined,
|
|
892
|
+
"aria-disabled": this.props.disabled ? "true" : undefined
|
|
893
|
+
}), this.props.children(clickableState));
|
|
1061
894
|
} else {
|
|
1062
|
-
return /*#__PURE__*/
|
|
895
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](StyledButton, _extends({}, commonProps, {
|
|
1063
896
|
type: "button",
|
|
1064
|
-
disabled:
|
|
1065
|
-
}),
|
|
897
|
+
disabled: this.props.disabled
|
|
898
|
+
}), this.props.children(clickableState));
|
|
1066
899
|
}
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
return _this;
|
|
900
|
+
};
|
|
1070
901
|
}
|
|
1071
902
|
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
safeWithNav: safeWithNav,
|
|
1122
|
-
onKeyDown: onKeyDown,
|
|
1123
|
-
onKeyUp: onKeyUp,
|
|
1124
|
-
target: target,
|
|
1125
|
-
disabled: disabled
|
|
1126
|
-
}, function (state, childrenProps) {
|
|
1127
|
-
return _this2.getCorrectTag(state, _objectSpread(_objectSpread({}, restProps), {}, {
|
|
1128
|
-
"data-test-id": testId,
|
|
1129
|
-
style: getStyle(state)
|
|
1130
|
-
}, childrenProps));
|
|
1131
|
-
});
|
|
1132
|
-
}
|
|
903
|
+
renderClickableBehavior(router) {
|
|
904
|
+
const {
|
|
905
|
+
href,
|
|
906
|
+
onClick,
|
|
907
|
+
skipClientNav,
|
|
908
|
+
beforeNav = undefined,
|
|
909
|
+
safeWithNav = undefined,
|
|
910
|
+
style,
|
|
911
|
+
target = undefined,
|
|
912
|
+
testId,
|
|
913
|
+
onKeyDown,
|
|
914
|
+
onKeyUp,
|
|
915
|
+
hideDefaultFocusRing,
|
|
916
|
+
light,
|
|
917
|
+
disabled,
|
|
918
|
+
...restProps
|
|
919
|
+
} = this.props;
|
|
920
|
+
const ClickableBehavior = Object(_util_get_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_6__[/* default */ "a"])(href, skipClientNav, router);
|
|
921
|
+
|
|
922
|
+
const getStyle = state => [styles.reset, styles.link, !hideDefaultFocusRing && state.focused && (light ? styles.focusedLight : styles.focused), style];
|
|
923
|
+
|
|
924
|
+
if (beforeNav) {
|
|
925
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](ClickableBehavior, {
|
|
926
|
+
href: href,
|
|
927
|
+
onClick: onClick,
|
|
928
|
+
beforeNav: beforeNav,
|
|
929
|
+
safeWithNav: safeWithNav,
|
|
930
|
+
onKeyDown: onKeyDown,
|
|
931
|
+
onKeyUp: onKeyUp,
|
|
932
|
+
disabled: disabled
|
|
933
|
+
}, (state, childrenProps) => this.getCorrectTag(state, router, { ...restProps,
|
|
934
|
+
"data-test-id": testId,
|
|
935
|
+
style: getStyle(state),
|
|
936
|
+
...childrenProps
|
|
937
|
+
}));
|
|
938
|
+
} else {
|
|
939
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](ClickableBehavior, {
|
|
940
|
+
href: href,
|
|
941
|
+
onClick: onClick,
|
|
942
|
+
safeWithNav: safeWithNav,
|
|
943
|
+
onKeyDown: onKeyDown,
|
|
944
|
+
onKeyUp: onKeyUp,
|
|
945
|
+
target: target,
|
|
946
|
+
disabled: disabled
|
|
947
|
+
}, (state, childrenProps) => this.getCorrectTag(state, router, { ...restProps,
|
|
948
|
+
"data-test-id": testId,
|
|
949
|
+
style: getStyle(state),
|
|
950
|
+
...childrenProps
|
|
951
|
+
}));
|
|
1133
952
|
}
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
return Clickable;
|
|
1137
|
-
}(external_react_["Component"]); // Source: https://gist.github.com/MoOx/9137295
|
|
953
|
+
}
|
|
1138
954
|
|
|
955
|
+
render() {
|
|
956
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react_router__WEBPACK_IMPORTED_MODULE_3__["__RouterContext"].Consumer, null, router => this.renderClickableBehavior(router));
|
|
957
|
+
}
|
|
1139
958
|
|
|
1140
|
-
|
|
1141
|
-
router: external_prop_types_["any"]
|
|
1142
|
-
});
|
|
959
|
+
} // Source: https://gist.github.com/MoOx/9137295
|
|
1143
960
|
|
|
1144
|
-
|
|
961
|
+
Clickable.defaultProps = {
|
|
1145
962
|
light: false,
|
|
1146
963
|
disabled: false,
|
|
1147
964
|
"aria-label": ""
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
var styles = external_aphrodite_["StyleSheet"].create({
|
|
965
|
+
};
|
|
966
|
+
const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
1152
967
|
reset: {
|
|
1153
968
|
border: "none",
|
|
1154
969
|
margin: 0,
|
|
@@ -1181,13 +996,69 @@ var styles = external_aphrodite_["StyleSheet"].create({
|
|
|
1181
996
|
cursor: "pointer"
|
|
1182
997
|
},
|
|
1183
998
|
focused: {
|
|
1184
|
-
outline:
|
|
999
|
+
outline: `solid 2px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].blue}`
|
|
1185
1000
|
},
|
|
1186
1001
|
focusedLight: {
|
|
1187
|
-
outline:
|
|
1002
|
+
outline: `solid 2px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].white}`
|
|
1188
1003
|
}
|
|
1189
1004
|
});
|
|
1190
|
-
|
|
1005
|
+
|
|
1006
|
+
/***/ }),
|
|
1007
|
+
/* 8 */
|
|
1008
|
+
/***/ (function(module, exports) {
|
|
1009
|
+
|
|
1010
|
+
module.exports = require("aphrodite");
|
|
1011
|
+
|
|
1012
|
+
/***/ }),
|
|
1013
|
+
/* 9 */
|
|
1014
|
+
/***/ (function(module, exports) {
|
|
1015
|
+
|
|
1016
|
+
module.exports = require("react-router");
|
|
1017
|
+
|
|
1018
|
+
/***/ }),
|
|
1019
|
+
/* 10 */
|
|
1020
|
+
/***/ (function(module, exports) {
|
|
1021
|
+
|
|
1022
|
+
function _extends() {
|
|
1023
|
+
module.exports = _extends = Object.assign || function (target) {
|
|
1024
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1025
|
+
var source = arguments[i];
|
|
1026
|
+
|
|
1027
|
+
for (var key in source) {
|
|
1028
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1029
|
+
target[key] = source[key];
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
return target;
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1037
|
+
module.exports["default"] = module.exports, module.exports.__esModule = true;
|
|
1038
|
+
return _extends.apply(this, arguments);
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
module.exports = _extends;
|
|
1042
|
+
module.exports["default"] = module.exports, module.exports.__esModule = true;
|
|
1043
|
+
|
|
1044
|
+
/***/ }),
|
|
1045
|
+
/* 11 */
|
|
1046
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1047
|
+
|
|
1048
|
+
"use strict";
|
|
1049
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1050
|
+
/* harmony import */ var _components_clickable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
|
|
1051
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _components_clickable_js__WEBPACK_IMPORTED_MODULE_0__["a"]; });
|
|
1052
|
+
|
|
1053
|
+
/* harmony import */ var _components_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
|
|
1054
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClickableBehavior", function() { return _components_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_1__["a"]; });
|
|
1055
|
+
|
|
1056
|
+
/* harmony import */ var _util_get_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
|
|
1057
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getClickableBehavior", function() { return _util_get_clickable_behavior_js__WEBPACK_IMPORTED_MODULE_2__["a"]; });
|
|
1058
|
+
|
|
1059
|
+
/* harmony import */ var _util_is_client_side_url_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1);
|
|
1060
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "isClientSideUrl", function() { return _util_is_client_side_url_js__WEBPACK_IMPORTED_MODULE_3__["a"]; });
|
|
1061
|
+
|
|
1191
1062
|
|
|
1192
1063
|
|
|
1193
1064
|
|