_id
stringlengths 2
6
| title
stringlengths 0
58
| partition
stringclasses 3
values | text
stringlengths 52
373k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q61900
|
val
|
validation
|
function val(node, _val2) {
if (node && node.el) {
var el = node.el;
if (_val2 !== undefined) {
el.value = _val2;
} else {
return el.value;
}
}
}
|
javascript
|
{
"resource": ""
}
|
q61901
|
on
|
validation
|
function on(element, ev, cb, context) {
for (var _len = arguments.length, args = Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++) {
args[_key - 4] = arguments[_key];
}
var _this = this;
var el = element.el,
events = ev.split(' '),
fn = function fn(e) {
cb.apply(context || _this, [e, element].concat(args));
};
events.forEach(function (event) {
el.addEventListener(event, fn);
});
var evt = {
remove: function remove() {
events.forEach(function (event) {
return el.removeEventListener(event, fn);
});
var evts = element._events;
evts.splice(evts.indexOf(evt), 1);
}
};
element._events.push(evt);
return evt;
}
|
javascript
|
{
"resource": ""
}
|
q61902
|
remove
|
validation
|
function remove(el) {
while (el._events.length > 0) {
el._events.shift().remove();
}
if (el.children) {
destroy(el.children);
}
if (el.elGroup !== undefined) {
el.elGroup.delete(el.el);
}
if (el.el !== undefined) {
if (el.el.remove) {
el.el.remove();
} else if (el.el.parentNode) {
el.el.parentNode.removeChild(el.el);
}
delete el.el;
}
}
|
javascript
|
{
"resource": ""
}
|
q61903
|
onDOMAttached
|
validation
|
function onDOMAttached(el) {
var _this2 = this;
var handlers = [],
attached = false,
_step = undefined;
if (el.el !== undefined) {
_step = function step() {
if (attached) {
while (handlers.length > 0) {
handlers.shift()();
}
} else {
window.requestAnimationFrame(_step);
if (document.body.contains(el.el)) {
attached = true;
}
}
};
}
return {
then: function then(cb, context) {
handlers.push(cb.bind(context || _this2));
window.requestAnimationFrame(_step);
}
};
}
|
javascript
|
{
"resource": ""
}
|
q61904
|
match
|
validation
|
function match({ just, nothing }) {
return function (maybe) {
for (const value of maybe) {
return just(value);
}
return nothing();
};
}
|
javascript
|
{
"resource": ""
}
|
q61905
|
flatMap
|
validation
|
function flatMap(mapper) {
return function (maybe) {
for (const value of maybe) {
return mapper(value);
}
return maybe_1.nothing();
};
}
|
javascript
|
{
"resource": ""
}
|
q61906
|
filter
|
validation
|
function filter(predicate) {
return flatMap(value => predicate(value) ? maybe_1.just(value) : maybe_1.nothing());
}
|
javascript
|
{
"resource": ""
}
|
q61907
|
or
|
validation
|
function or(defaultValue) {
return function (maybe) {
for (const value of maybe) {
return maybe_1.just(value);
}
return defaultValue;
};
}
|
javascript
|
{
"resource": ""
}
|
q61908
|
validation
|
function(e){
var history=S.History, current = history.getFragment();
if(OLD_IE && current == history.fragment && history.iframe) current = history.getFragment(history.getHash(history.iframe));
if(current == history.fragment) return false;
if(history.iframe) history.navigate(current);
history.loadUrl();
}
|
javascript
|
{
"resource": ""
}
|
|
q61909
|
validation
|
function(fragmentOverride,state){
var fragment = baseUrl+( this.fragment = this.getFragment(fragmentOverride));
if(fragment){
var a=$('a[href="'+fragment+'"]');
a.length===0 ? S.redirect(fragment) : a.click();
}
}
|
javascript
|
{
"resource": ""
}
|
|
q61910
|
createInstance
|
test
|
function createInstance(defaultConfig) {
var context = new Axios(defaultConfig);
var instance = bind(Axios.prototype.request, context);
// Copy axios.prototype to instance
utils.extend(instance, Axios.prototype, context);
// Copy context to instance
utils.extend(instance, context);
return instance;
}
|
javascript
|
{
"resource": ""
}
|
q61911
|
CancelToken
|
test
|
function CancelToken(executor) {
if (typeof executor !== 'function') {
throw new TypeError('executor must be a function.');
}
var resolvePromise;
this.promise = new Promise(function promiseExecutor(resolve) {
resolvePromise = resolve;
});
var token = this;
executor(function cancel(message) {
if (token.reason) {
// Cancellation has already been requested
return;
}
token.reason = new Cancel(message);
resolvePromise(token.reason);
});
}
|
javascript
|
{
"resource": ""
}
|
q61912
|
isArrayBufferView
|
test
|
function isArrayBufferView(val) {
var result;
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
result = ArrayBuffer.isView(val);
} else {
result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
}
return result;
}
|
javascript
|
{
"resource": ""
}
|
q61913
|
isStandardBrowserEnv
|
test
|
function isStandardBrowserEnv() {
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
navigator.product === 'NativeScript' ||
navigator.product === 'NS')) {
return false;
}
return (
typeof window !== 'undefined' &&
typeof document !== 'undefined'
);
}
|
javascript
|
{
"resource": ""
}
|
q61914
|
forEach
|
test
|
function forEach(obj, fn) {
// Don't bother if no value provided
if (obj === null || typeof obj === 'undefined') {
return;
}
// Force an array if not already something iterable
if (typeof obj !== 'object') {
/*eslint no-param-reassign:0*/
obj = [obj];
}
if (isArray(obj)) {
// Iterate over array values
for (var i = 0, l = obj.length; i < l; i++) {
fn.call(null, obj[i], i, obj);
}
} else {
// Iterate over object keys
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
fn.call(null, obj[key], key, obj);
}
}
}
}
|
javascript
|
{
"resource": ""
}
|
q61915
|
extend
|
test
|
function extend(a, b, thisArg) {
forEach(b, function assignValue(val, key) {
if (thisArg && typeof val === 'function') {
a[key] = bind(val, thisArg);
} else {
a[key] = val;
}
});
return a;
}
|
javascript
|
{
"resource": ""
}
|
q61916
|
writePackageManifest
|
test
|
function writePackageManifest (packageName) {
const packagePath = require.resolve(packageName + '/package.json')
let { name, main, author, license, types, typings } = require(packagePath)
if (!main) {
main = 'index.js'
}
let typesFile = types || typings
if (typesFile) {
typesFile = require.resolve(join(packageName, typesFile))
}
const compiledPackagePath = join(__dirname, `dist/compiled/${packageName}`)
const potentialLicensePath = join(dirname(packagePath), './LICENSE')
if (existsSync(potentialLicensePath)) {
this._.files.push({
dir: compiledPackagePath,
base: 'LICENSE',
data: readFileSync(potentialLicensePath, 'utf8')
})
}
this._.files.push({
dir: compiledPackagePath,
base: 'package.json',
data:
JSON.stringify(
Object.assign(
{},
{ name, main: `${basename(main, '.' + extname(main))}` },
author ? { author } : undefined,
license ? { license } : undefined,
typesFile
? {
types: relative(compiledPackagePath, typesFile)
}
: undefined
)
) + '\n'
})
}
|
javascript
|
{
"resource": ""
}
|
q61917
|
processMessage
|
test
|
function processMessage (e) {
const obj = JSON.parse(e.data)
switch (obj.action) {
case 'building': {
console.log(
'[HMR] bundle ' + (obj.name ? "'" + obj.name + "' " : '') +
'rebuilding'
)
break
}
case 'built':
case 'sync': {
clearOutdatedErrors()
if (obj.hash) {
handleAvailableHash(obj.hash)
}
if (obj.warnings.length > 0) {
handleWarnings(obj.warnings)
}
if (obj.errors.length > 0) {
// When there is a compilation error coming from SSR we have to reload the page on next successful compile
if (obj.action === 'sync') {
hadRuntimeError = true
}
handleErrors(obj.errors)
break
}
handleSuccess()
break
}
default: {
if (customHmrEventHandler) {
customHmrEventHandler(obj)
break
}
break
}
}
}
|
javascript
|
{
"resource": ""
}
|
q61918
|
tryApplyUpdates
|
test
|
async function tryApplyUpdates (onHotUpdateSuccess) {
if (!module.hot) {
// HotModuleReplacementPlugin is not in Webpack configuration.
console.error('HotModuleReplacementPlugin is not in Webpack configuration.')
// window.location.reload();
return
}
if (!isUpdateAvailable() || !canApplyUpdates()) {
return
}
function handleApplyUpdates (err, updatedModules) {
if (err || hadRuntimeError) {
if (err) {
console.warn('Error while applying updates, reloading page', err)
}
if (hadRuntimeError) {
console.warn('Had runtime error previously, reloading page')
}
window.location.reload()
return
}
if (typeof onHotUpdateSuccess === 'function') {
// Maybe we want to do something.
onHotUpdateSuccess()
}
if (isUpdateAvailable()) {
// While we were updating, there was a new update! Do it again.
tryApplyUpdates()
}
}
// https://webpack.github.io/docs/hot-module-replacement.html#check
try {
const updatedModules = await module.hot.check(/* autoApply */ {
ignoreUnaccepted: true
})
if (updatedModules) {
handleApplyUpdates(null, updatedModules)
}
} catch (err) {
handleApplyUpdates(err, null)
}
}
|
javascript
|
{
"resource": ""
}
|
q61919
|
tryApplyUpdates
|
test
|
async function tryApplyUpdates () {
if (!isUpdateAvailable() || !canApplyUpdates()) {
return
}
try {
const res = await fetch(`${hotUpdatePath}${curHash}.hot-update.json`)
const data = await res.json()
const curPage = page === '/' ? 'index' : page
const pageUpdated = Object.keys(data.c)
.some(mod => {
return (
mod.indexOf(`pages${curPage.substr(0, 1) === '/' ? curPage : `/${curPage}`}`) !== -1 ||
mod.indexOf(`pages${curPage.substr(0, 1) === '/' ? curPage : `/${curPage}`}`.replace(/\//g, '\\')) !== -1
)
})
if (pageUpdated) {
document.location.reload(true)
} else {
curHash = mostRecentHash
}
} catch (err) {
console.error('Error occurred checking for update', err)
document.location.reload(true)
}
}
|
javascript
|
{
"resource": ""
}
|
q61920
|
formatMessage
|
test
|
function formatMessage (message, isError) {
let lines = message.split('\n')
// Strip Webpack-added headers off errors/warnings
// https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
lines = lines.filter(line => !/Module [A-z ]+\(from/.test(line))
// Transform parsing error into syntax error
// TODO: move this to our ESLint formatter?
lines = lines.map(line => {
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
line
)
if (!parsingError) {
return line
}
const [, errorLine, errorColumn, errorMessage] = parsingError
return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`
})
message = lines.join('\n')
// Smoosh syntax errors (commonly found in CSS)
message = message.replace(
/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
`${friendlySyntaxErrorLabel} $3 ($1:$2)\n`
)
// Remove columns from ESLint formatter output (we added these for more
// accurate syntax errors)
message = message.replace(/Line (\d+):\d+:/g, 'Line $1:')
// Clean up export errors
message = message.replace(
/^.*export '(.+?)' was not found in '(.+?)'.*$/gm,
`Attempted import error: '$1' is not exported from '$2'.`
)
message = message.replace(
/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm,
`Attempted import error: '$2' does not contain a default export (imported as '$1').`
)
message = message.replace(
/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm,
`Attempted import error: '$1' is not exported from '$3' (imported as '$2').`
)
lines = message.split('\n')
// Remove leading newline
if (lines.length > 2 && lines[1].trim() === '') {
lines.splice(1, 1)
}
// Clean up file name
lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1')
// Cleans up verbose "module not found" messages for files and packages.
if (lines[1] && lines[1].indexOf('Module not found: ') === 0) {
lines = [
lines[0],
lines[1]
.replace('Error: ', '')
.replace('Module not found: Cannot find file:', 'Cannot find file:')
]
}
message = lines.join('\n')
// Internal stacks are generally useless so we strip them... with the
// exception of stacks containing `webpack:` because they're normally
// from user code generated by Webpack. For more information see
// https://github.com/facebook/create-react-app/pull/1050
message = message.replace(
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
''
) // at ... ...:x:y
message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, '') // at <anonymous>
lines = message.split('\n')
// Remove duplicated newlines
lines = lines.filter(
(line, index, arr) =>
index === 0 || line.trim() !== '' || line.trim() !== arr[index - 1].trim()
)
// Reassemble the message
message = lines.join('\n')
return message.trim()
}
|
javascript
|
{
"resource": ""
}
|
q61921
|
UDecimalPad
|
test
|
function UDecimalPad(num, precision) {
var value = UDecimalString(num);
assert.equal("number", typeof precision === 'undefined' ? 'undefined' : (0, _typeof3.default)(precision), "precision");
var part = value.split(".");
if (precision === 0 && part.length === 1) {
return part[0];
}
if (part.length === 1) {
return part[0] + '.' + "0".repeat(precision);
} else {
var pad = precision - part[1].length;
assert(pad >= 0, 'decimal \'' + value + '\' exceeds precision ' + precision);
return part[0] + '.' + part[1] + "0".repeat(pad);
}
}
|
javascript
|
{
"resource": ""
}
|
q61922
|
parseSegment
|
test
|
function parseSegment(buffer, offset) {
let typeKey = buffer[offset];
if (typeKey <= 20) {
if (buffer[offset + 1] == undefined) throw new Error("ParseError: No value for uint8");
return { typeKey: typeKey, value: buffer[offset + 1], bufferLength: 2 };
}
if (typeKey <= 40) {
if (buffer[offset + 2] == undefined) throw new Error("ParseError: Incomplete value for uint16");
return { typeKey: typeKey, value: buffer.readUInt16BE(offset + 1), bufferLength: 3 };
}
else if (typeKey <= 90) {
if (buffer[offset + 4] == undefined) throw new Error("ParseError: Incomplete value for uint32");
return { typeKey: typeKey, value: buffer.readUInt32BE(offset + 1), bufferLength: 5 };
}
else if (typeKey <= 155) {
if (buffer[offset + 1] == undefined) throw new Error("ParseError: Incomplete length value for string");
let len = buffer.readUInt8(offset + 1);
if (buffer[offset + 1 + len] == undefined) throw new Error("ParseError: Incomplete value for string");
let value = buffer.toString("utf8", offset + 2, offset + 2 + len);
return { typeKey: typeKey, value: value, bufferLength: 2 + len };
}
else if (typeKey <= 165) {
if (buffer[offset + 16] == undefined) throw new Error("ParseError: Incomplete value for uuid");
let len = 16;
let value = new Buffer(len);
buffer.copy(value, 0, offset + 1, offset + 1 + len);
return { typeKey: typeKey, value: value, bufferLength: 1 + len };
}
else if (typeKey <= 180) {
if (buffer[offset + 1] == undefined) throw new Error("ParseError: Incomplete length value for byte string");
let len = buffer.readUInt8(offset + 1);
if (buffer[offset + len + 1] == undefined) throw new Error("ParseError: Incomplete value for byte string");
let value = new Buffer(len);
buffer.copy(value, 0, offset + 2, offset + 2 + len);
return { typeKey: typeKey, value: value, bufferLength: 2 + len };
}
else {
throw new Error("typeKey not supported");
}
}
|
javascript
|
{
"resource": ""
}
|
q61923
|
parseSegments
|
test
|
function parseSegments(buffer) {
if (buffer.length == 0) throw new Error("bad segments stream");
let pointer = 0;
let segments = [ ];
while (pointer < buffer.length) {
let seg = parseSegment(buffer, pointer);
segments.push(seg);
pointer += seg.bufferLength;
delete seg.bufferLength;
}
if (pointer != buffer.length) {
throw new Error("Bad / incomplete segments");
}
return segments;
}
|
javascript
|
{
"resource": ""
}
|
q61924
|
parseQRCode
|
test
|
function parseQRCode(text, options) {
if (text.length < 3 || text.length > 2000) throw new Error("Invalid length of EvtLink");
let textSplited = text.split("_");
if (textSplited.length > 2) return null;
let rawText;
if (textSplited[0].startsWith(qrPrefix)) {
rawText = textSplited[0].substr(qrPrefix.length);
}
else {
rawText = textSplited[0];
}
// decode segments base42
let segmentsBytes = EvtLink.dec2b(rawText);
if (segmentsBytes.length < 2) throw new Error("no flag in segment");
let flag = segmentsBytes.readInt16BE(0);
if ((flag & 1) == 0) { // check version of EvtLink
throw new Error("The EvtLink is invalid or its version is newer than version 1 and is not supported by evtjs yet");
}
let segmentsBytesRaw = new Buffer(segmentsBytes.length - 2);
segmentsBytes.copy(segmentsBytesRaw, 0, 2, segmentsBytes.length);
let publicKeys = [ ];
let signatures = [ ];
if (textSplited[1]) {
let buf = EvtLink.dec2b(textSplited[1]);
let i = 0;
if (buf.length % 65 !== 0) {
throw new Error("length of signature is invalid");
}
while (i * 65 < buf.length) {
let current = new Buffer(65);
buf.copy(current, 0, i * 65, i * 65 + 65);
let signature = ecc.Signature.fromBuffer(current);
signatures.push(signature.toString());
if (!options || options.recoverPublicKeys) {
publicKeys.push(signature.recover(segmentsBytes).toString());
}
++i;
}
}
return { flag, segments: parseSegments(segmentsBytesRaw), publicKeys, signatures };
}
|
javascript
|
{
"resource": ""
}
|
q61925
|
__calcKeyProvider
|
test
|
async function __calcKeyProvider(keyProvider) {
if (!keyProvider) { return []; }
// if keyProvider is function
if (keyProvider.apply && keyProvider.call) {
keyProvider = keyProvider();
}
// resolve for Promise
keyProvider = await Promise.resolve(keyProvider);
if (!Array.isArray(keyProvider)) {
keyProvider = [ keyProvider ];
}
for (let key of keyProvider) {
if (!EvtKey.isValidPrivateKey(key)) {
throw new Error("Invalid private key");
}
}
return keyProvider;
}
|
javascript
|
{
"resource": ""
}
|
q61926
|
random32ByteBuffer
|
test
|
function random32ByteBuffer({cpuEntropyBits = 0, safe = true} = {}) {
assert.equal(typeof cpuEntropyBits, "number", "cpuEntropyBits");
assert.equal(typeof safe, "boolean", "boolean");
if(safe) {
assert(entropyCount >= 128, "Call initialize() to add entropy (current: " + entropyCount + ")");
}
// if(entropyCount > 0) {
// console.log(`Additional private key entropy: ${entropyCount} events`)
// }
const hash_array = [];
hash_array.push(randomBytes(32));
hash_array.push(Buffer.from(cpuEntropy(cpuEntropyBits)));
hash_array.push(externalEntropyArray);
hash_array.push(browserEntropy());
return hash.sha256(Buffer.concat(hash_array));
}
|
javascript
|
{
"resource": ""
}
|
q61927
|
addEntropy
|
test
|
function addEntropy(...ints) {
assert.equal(externalEntropyArray.length, 101, "externalEntropyArray");
entropyCount += ints.length;
for(const i of ints) {
const pos = entropyPos++ % 101;
const i2 = externalEntropyArray[pos] += i;
if(i2 > 9007199254740991)
externalEntropyArray[pos] = 0;
}
}
|
javascript
|
{
"resource": ""
}
|
q61928
|
cpuEntropy
|
test
|
function cpuEntropy(cpuEntropyBits = 128) {
let collected = [];
let lastCount = null;
let lowEntropySamples = 0;
while(collected.length < cpuEntropyBits) {
const count = floatingPointCount();
if(lastCount != null) {
const delta = count - lastCount;
if(Math.abs(delta) < 1) {
lowEntropySamples++;
continue;
}
// how many bits of entropy were in this sample
const bits = Math.floor(log2(Math.abs(delta)) + 1);
if(bits < 4) {
if(bits < 2) {
lowEntropySamples++;
}
continue;
}
collected.push(delta);
}
lastCount = count;
}
if(lowEntropySamples > 10) {
const pct = Number(lowEntropySamples / cpuEntropyBits * 100).toFixed(2);
// Is this algorithm getting inefficient?
console.warn(`WARN: ${pct}% low CPU entropy re-sampled`);
}
return collected;
}
|
javascript
|
{
"resource": ""
}
|
q61929
|
cryptoJsDecrypt
|
test
|
function cryptoJsDecrypt(message, key, iv) {
assert(message, "Missing cipher text");
message = toBinaryBuffer(message);
const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
// decipher.setAutoPadding(true)
message = Buffer.concat([decipher.update(message), decipher.final()]);
return message;
}
|
javascript
|
{
"resource": ""
}
|
q61930
|
initialize
|
test
|
function initialize() {
if(initialized) {
return;
}
unitTest();
keyUtils.addEntropy(...keyUtils.cpuEntropy());
assert(keyUtils.entropyCount() >= 128, "insufficient entropy");
initialized = true;
}
|
javascript
|
{
"resource": ""
}
|
q61931
|
montConvert
|
test
|
function montConvert(x) {
var r = new BigInteger()
x.abs()
.dlShiftTo(this.m.t, r)
r.divRemTo(this.m, null, r)
if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r)
return r
}
|
javascript
|
{
"resource": ""
}
|
q61932
|
verify
|
test
|
function verify(data, pubkey, encoding = "utf8") {
if (typeof data === "string") {
data = Buffer.from(data, encoding);
}
assert(Buffer.isBuffer(data), "data is a required String or Buffer");
data = hash.sha256(data);
return verifyHash(data, pubkey);
}
|
javascript
|
{
"resource": ""
}
|
q61933
|
recover
|
test
|
function recover(data, encoding = "utf8") {
if (typeof data === "string") {
data = Buffer.from(data, encoding);
}
assert(Buffer.isBuffer(data), "data is a required String or Buffer");
data = hash.sha256(data);
return recoverHash(data);
}
|
javascript
|
{
"resource": ""
}
|
q61934
|
invokeWith
|
test
|
function invokeWith(msg) {
// Debugging can be done using println like this
print('Finding comments in ' + msg.getRequestHeader().getURI().toString());
var body = msg.getResponseBody().toString()
// Look for html comments
if (body.indexOf('<!--') > 0) {
var o = body.indexOf('<!--');
while (o > 0) {
var e = body.indexOf('-->', o);
print("\t" + body.substr(o,e-o+3))
o = body.indexOf('<!--', e);
}
}
}
|
javascript
|
{
"resource": ""
}
|
q61935
|
FormGroup
|
test
|
function FormGroup(props) {
const { children, className, grouped, inline, unstackable, widths } = props
const classes = cx(
useKeyOnly(grouped, 'grouped'),
useKeyOnly(inline, 'inline'),
useKeyOnly(unstackable, 'unstackable'),
useWidthProp(widths, null, true),
'fields',
className,
)
const rest = getUnhandledProps(FormGroup, props)
const ElementType = getElementType(FormGroup, props)
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61936
|
Loader
|
test
|
function Loader(props) {
const {
active,
children,
className,
content,
disabled,
indeterminate,
inline,
inverted,
size,
} = props
const classes = cx(
'ui',
size,
useKeyOnly(active, 'active'),
useKeyOnly(disabled, 'disabled'),
useKeyOnly(indeterminate, 'indeterminate'),
useKeyOnly(inverted, 'inverted'),
useKeyOnly(children || content, 'text'),
useKeyOrValueAndKey(inline, 'inline'),
'loader',
className,
)
const rest = getUnhandledProps(Loader, props)
const ElementType = getElementType(Loader, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61937
|
ItemContent
|
test
|
function ItemContent(props) {
const { children, className, content, description, extra, header, meta, verticalAlign } = props
const classes = cx(useVerticalAlignProp(verticalAlign), 'content', className)
const rest = getUnhandledProps(ItemContent, props)
const ElementType = getElementType(ItemContent, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{ItemHeader.create(header, { autoGenerateKey: false })}
{ItemMeta.create(meta, { autoGenerateKey: false })}
{ItemDescription.create(description, { autoGenerateKey: false })}
{ItemExtra.create(extra, { autoGenerateKey: false })}
{content}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61938
|
Table
|
test
|
function Table(props) {
const {
attached,
basic,
celled,
children,
className,
collapsing,
color,
columns,
compact,
definition,
fixed,
footerRow,
headerRow,
headerRows,
inverted,
padded,
renderBodyRow,
selectable,
singleLine,
size,
sortable,
stackable,
striped,
structured,
tableData,
textAlign,
unstackable,
verticalAlign,
} = props
const classes = cx(
'ui',
color,
size,
useKeyOnly(celled, 'celled'),
useKeyOnly(collapsing, 'collapsing'),
useKeyOnly(definition, 'definition'),
useKeyOnly(fixed, 'fixed'),
useKeyOnly(inverted, 'inverted'),
useKeyOnly(selectable, 'selectable'),
useKeyOnly(singleLine, 'single line'),
useKeyOnly(sortable, 'sortable'),
useKeyOnly(stackable, 'stackable'),
useKeyOnly(striped, 'striped'),
useKeyOnly(structured, 'structured'),
useKeyOnly(unstackable, 'unstackable'),
useKeyOrValueAndKey(attached, 'attached'),
useKeyOrValueAndKey(basic, 'basic'),
useKeyOrValueAndKey(compact, 'compact'),
useKeyOrValueAndKey(padded, 'padded'),
useTextAlignProp(textAlign),
useVerticalAlignProp(verticalAlign),
useWidthProp(columns, 'column'),
'table',
className,
)
const rest = getUnhandledProps(Table, props)
const ElementType = getElementType(Table, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
const hasHeaderRows = headerRow || headerRows
const headerShorthandOptions = { defaultProps: { cellAs: 'th' } }
const headerElement = hasHeaderRows && (
<TableHeader>
{TableRow.create(headerRow, headerShorthandOptions)}
{_.map(headerRows, (data) => TableRow.create(data, headerShorthandOptions))}
</TableHeader>
)
return (
<ElementType {...rest} className={classes}>
{headerElement}
<TableBody>
{renderBodyRow &&
_.map(tableData, (data, index) => TableRow.create(renderBodyRow(data, index)))}
</TableBody>
{footerRow && <TableFooter>{TableRow.create(footerRow)}</TableFooter>}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61939
|
Rail
|
test
|
function Rail(props) {
const {
attached,
children,
className,
close,
content,
dividing,
internal,
position,
size,
} = props
const classes = cx(
'ui',
position,
size,
useKeyOnly(attached, 'attached'),
useKeyOnly(dividing, 'dividing'),
useKeyOnly(internal, 'internal'),
useKeyOrValueAndKey(close, 'close'),
'rail',
className,
)
const rest = getUnhandledProps(Rail, props)
const ElementType = getElementType(Rail, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61940
|
ButtonGroup
|
test
|
function ButtonGroup(props) {
const {
attached,
basic,
buttons,
children,
className,
color,
compact,
content,
floated,
fluid,
icon,
inverted,
labeled,
negative,
positive,
primary,
secondary,
size,
toggle,
vertical,
widths,
} = props
const classes = cx(
'ui',
color,
size,
useKeyOnly(basic, 'basic'),
useKeyOnly(compact, 'compact'),
useKeyOnly(fluid, 'fluid'),
useKeyOnly(icon, 'icon'),
useKeyOnly(inverted, 'inverted'),
useKeyOnly(labeled, 'labeled'),
useKeyOnly(negative, 'negative'),
useKeyOnly(positive, 'positive'),
useKeyOnly(primary, 'primary'),
useKeyOnly(secondary, 'secondary'),
useKeyOnly(toggle, 'toggle'),
useKeyOnly(vertical, 'vertical'),
useKeyOrValueAndKey(attached, 'attached'),
useValueAndKey(floated, 'floated'),
useWidthProp(widths),
'buttons',
className,
)
const rest = getUnhandledProps(ButtonGroup, props)
const ElementType = getElementType(ButtonGroup, props)
if (_.isNil(buttons)) {
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{_.map(buttons, button => Button.create(button))}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61941
|
GridRow
|
test
|
function GridRow(props) {
const {
centered,
children,
className,
color,
columns,
divided,
only,
reversed,
stretched,
textAlign,
verticalAlign,
} = props
const classes = cx(
color,
useKeyOnly(centered, 'centered'),
useKeyOnly(divided, 'divided'),
useKeyOnly(stretched, 'stretched'),
useMultipleProp(only, 'only'),
useMultipleProp(reversed, 'reversed'),
useTextAlignProp(textAlign),
useVerticalAlignProp(verticalAlign),
useWidthProp(columns, 'column', true),
'row',
className,
)
const rest = getUnhandledProps(GridRow, props)
const ElementType = getElementType(GridRow, props)
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61942
|
FormField
|
test
|
function FormField(props) {
const {
children,
className,
content,
control,
disabled,
error,
inline,
label,
required,
type,
width,
} = props
const classes = cx(
useKeyOnly(disabled, 'disabled'),
useKeyOnly(error, 'error'),
useKeyOnly(inline, 'inline'),
useKeyOnly(required, 'required'),
useWidthProp(width, 'wide'),
'field',
className,
)
const rest = getUnhandledProps(FormField, props)
const ElementType = getElementType(FormField, props)
// ----------------------------------------
// No Control
// ----------------------------------------
if (_.isNil(control)) {
if (_.isNil(label)) {
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{createHTMLLabel(label, { autoGenerateKey: false })}
</ElementType>
)
}
// ----------------------------------------
// Checkbox/Radio Control
// ----------------------------------------
const controlProps = { ...rest, content, children, disabled, required, type }
// wrap HTML checkboxes/radios in the label
if (control === 'input' && (type === 'checkbox' || type === 'radio')) {
return (
<ElementType className={classes}>
<label>
{createElement(control, controlProps)} {label}
</label>
</ElementType>
)
}
// pass label prop to controls that support it
if (control === Checkbox || control === Radio) {
return (
<ElementType className={classes}>
{createElement(control, { ...controlProps, label })}
</ElementType>
)
}
// ----------------------------------------
// Other Control
// ----------------------------------------
return (
<ElementType className={classes}>
{createHTMLLabel(label, {
defaultProps: { htmlFor: _.get(controlProps, 'id') },
autoGenerateKey: false,
})}
{createElement(control, controlProps)}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61943
|
CardContent
|
test
|
function CardContent(props) {
const { children, className, content, description, extra, header, meta, textAlign } = props
const classes = cx(useKeyOnly(extra, 'extra'), useTextAlignProp(textAlign), 'content', className)
const rest = getUnhandledProps(CardContent, props)
const ElementType = getElementType(CardContent, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
if (!childrenUtils.isNil(content)) {
return (
<ElementType {...rest} className={classes}>
{content}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{createShorthand(CardHeader, val => ({ content: val }), header, { autoGenerateKey: false })}
{createShorthand(CardMeta, val => ({ content: val }), meta, { autoGenerateKey: false })}
{createShorthand(CardDescription, val => ({ content: val }), description, {
autoGenerateKey: false,
})}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61944
|
Item
|
test
|
function Item(props) {
const { children, className, content, description, extra, header, image, meta } = props
const classes = cx('item', className)
const rest = getUnhandledProps(Item, props)
const ElementType = getElementType(Item, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{ItemImage.create(image, { autoGenerateKey: false })}
<ItemContent
content={content}
description={description}
extra={extra}
header={header}
meta={meta}
/>
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61945
|
CommentAvatar
|
test
|
function CommentAvatar(props) {
const { className, src } = props
const classes = cx('avatar', className)
const rest = getUnhandledProps(CommentAvatar, props)
const [imageProps, rootProps] = partitionHTMLProps(rest, { htmlProps: htmlImageProps })
const ElementType = getElementType(CommentAvatar, props)
return (
<ElementType {...rootProps} className={classes}>
{createHTMLImage(src, { autoGenerateKey: false, defaultProps: imageProps })}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61946
|
StatisticLabel
|
test
|
function StatisticLabel(props) {
const { children, className, content } = props
const classes = cx('label', className)
const rest = getUnhandledProps(StatisticLabel, props)
const ElementType = getElementType(StatisticLabel, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61947
|
FeedMeta
|
test
|
function FeedMeta(props) {
const { children, className, content, like } = props
const classes = cx('meta', className)
const rest = getUnhandledProps(FeedMeta, props)
const ElementType = getElementType(FeedMeta, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{createShorthand(FeedLike, val => ({ content: val }), like, { autoGenerateKey: false })}
{content}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61948
|
Container
|
test
|
function Container(props) {
const { children, className, content, fluid, text, textAlign } = props
const classes = cx(
'ui',
useKeyOnly(text, 'text'),
useKeyOnly(fluid, 'fluid'),
useTextAlignProp(textAlign),
'container',
className,
)
const rest = getUnhandledProps(Container, props)
const ElementType = getElementType(Container, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61949
|
StepGroup
|
test
|
function StepGroup(props) {
const {
attached,
children,
className,
content,
fluid,
items,
ordered,
size,
stackable,
unstackable,
vertical,
widths,
} = props
const classes = cx(
'ui',
size,
useKeyOnly(fluid, 'fluid'),
useKeyOnly(ordered, 'ordered'),
useKeyOnly(unstackable, 'unstackable'),
useKeyOnly(vertical, 'vertical'),
useKeyOrValueAndKey(attached, 'attached'),
useValueAndKey(stackable, 'stackable'),
useWidthProp(widths),
'steps',
className,
)
const rest = getUnhandledProps(StepGroup, props)
const ElementType = getElementType(StepGroup, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
if (!childrenUtils.isNil(content)) {
return (
<ElementType {...rest} className={classes}>
{content}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{_.map(items, item => Step.create(item))}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61950
|
Divider
|
test
|
function Divider(props) {
const {
children,
className,
clearing,
content,
fitted,
hidden,
horizontal,
inverted,
section,
vertical,
} = props
const classes = cx(
'ui',
useKeyOnly(clearing, 'clearing'),
useKeyOnly(fitted, 'fitted'),
useKeyOnly(hidden, 'hidden'),
useKeyOnly(horizontal, 'horizontal'),
useKeyOnly(inverted, 'inverted'),
useKeyOnly(section, 'section'),
useKeyOnly(vertical, 'vertical'),
'divider',
className,
)
const rest = getUnhandledProps(Divider, props)
const ElementType = getElementType(Divider, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61951
|
Header
|
test
|
function Header(props) {
const {
attached,
block,
children,
className,
color,
content,
disabled,
dividing,
floated,
icon,
image,
inverted,
size,
sub,
subheader,
textAlign,
} = props
const classes = cx(
'ui',
color,
size,
useKeyOnly(block, 'block'),
useKeyOnly(disabled, 'disabled'),
useKeyOnly(dividing, 'dividing'),
useValueAndKey(floated, 'floated'),
useKeyOnly(icon === true, 'icon'),
useKeyOnly(image === true, 'image'),
useKeyOnly(inverted, 'inverted'),
useKeyOnly(sub, 'sub'),
useKeyOrValueAndKey(attached, 'attached'),
useTextAlignProp(textAlign),
'header',
className,
)
const rest = getUnhandledProps(Header, props)
const ElementType = getElementType(Header, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
const iconElement = Icon.create(icon, { autoGenerateKey: false })
const imageElement = Image.create(image, { autoGenerateKey: false })
const subheaderElement = HeaderSubheader.create(subheader, { autoGenerateKey: false })
if (iconElement || imageElement) {
return (
<ElementType {...rest} className={classes}>
{iconElement || imageElement}
{(content || subheaderElement) && (
<HeaderContent>
{content}
{subheaderElement}
</HeaderContent>
)}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{content}
{subheaderElement}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61952
|
Grid
|
test
|
function Grid(props) {
const {
celled,
centered,
children,
className,
columns,
container,
divided,
doubling,
inverted,
padded,
relaxed,
reversed,
stackable,
stretched,
textAlign,
verticalAlign,
} = props
const classes = cx(
'ui',
useKeyOnly(centered, 'centered'),
useKeyOnly(container, 'container'),
useKeyOnly(doubling, 'doubling'),
useKeyOnly(inverted, 'inverted'),
useKeyOnly(stackable, 'stackable'),
useKeyOnly(stretched, 'stretched'),
useKeyOrValueAndKey(celled, 'celled'),
useKeyOrValueAndKey(divided, 'divided'),
useKeyOrValueAndKey(padded, 'padded'),
useKeyOrValueAndKey(relaxed, 'relaxed'),
useMultipleProp(reversed, 'reversed'),
useTextAlignProp(textAlign),
useVerticalAlignProp(verticalAlign),
useWidthProp(columns, 'column', true),
'grid',
className,
)
const rest = getUnhandledProps(Grid, props)
const ElementType = getElementType(Grid, props)
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61953
|
Breadcrumb
|
test
|
function Breadcrumb(props) {
const { children, className, divider, icon, sections, size } = props
const classes = cx('ui', size, 'breadcrumb', className)
const rest = getUnhandledProps(Breadcrumb, props)
const ElementType = getElementType(Breadcrumb, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
const childElements = []
_.each(sections, (section, index) => {
// section
const breadcrumbElement = BreadcrumbSection.create(section)
childElements.push(breadcrumbElement)
// divider
if (index !== sections.length - 1) {
const key = `${breadcrumbElement.key}_divider` || JSON.stringify(section)
childElements.push(BreadcrumbDivider.create({ content: divider, icon, key }))
}
})
return (
<ElementType {...rest} className={classes}>
{childElements}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61954
|
CardDescription
|
test
|
function CardDescription(props) {
const { children, className, content, textAlign } = props
const classes = cx(useTextAlignProp(textAlign), 'description', className)
const rest = getUnhandledProps(CardDescription, props)
const ElementType = getElementType(CardDescription, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61955
|
ItemGroup
|
test
|
function ItemGroup(props) {
const { children, className, content, divided, items, link, relaxed, unstackable } = props
const classes = cx(
'ui',
useKeyOnly(divided, 'divided'),
useKeyOnly(link, 'link'),
useKeyOnly(unstackable, 'unstackable'),
useKeyOrValueAndKey(relaxed, 'relaxed'),
'items',
className,
)
const rest = getUnhandledProps(ItemGroup, props)
const ElementType = getElementType(ItemGroup, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
if (!childrenUtils.isNil(content)) {
return (
<ElementType {...rest} className={classes}>
{content}
</ElementType>
)
}
const itemsJSX = _.map(items, (item) => {
const { childKey, ...itemProps } = item
const finalKey =
childKey ||
[itemProps.content, itemProps.description, itemProps.header, itemProps.meta].join('-')
return <Item {...itemProps} key={finalKey} />
})
return (
<ElementType {...rest} className={classes}>
{itemsJSX}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61956
|
GridColumn
|
test
|
function GridColumn(props) {
const {
children,
className,
computer,
color,
floated,
largeScreen,
mobile,
only,
stretched,
tablet,
textAlign,
verticalAlign,
widescreen,
width,
} = props
const classes = cx(
color,
useKeyOnly(stretched, 'stretched'),
useMultipleProp(only, 'only'),
useTextAlignProp(textAlign),
useValueAndKey(floated, 'floated'),
useVerticalAlignProp(verticalAlign),
useWidthProp(computer, 'wide computer'),
useWidthProp(largeScreen, 'wide large screen'),
useWidthProp(mobile, 'wide mobile'),
useWidthProp(tablet, 'wide tablet'),
useWidthProp(widescreen, 'wide widescreen'),
useWidthProp(width, 'wide'),
'column',
className,
)
const rest = getUnhandledProps(GridColumn, props)
const ElementType = getElementType(GridColumn, props)
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61957
|
ItemImage
|
test
|
function ItemImage(props) {
const { size } = props
const rest = getUnhandledProps(ItemImage, props)
return <Image {...rest} size={size} ui={!!size} wrapped />
}
|
javascript
|
{
"resource": ""
}
|
q61958
|
CardGroup
|
test
|
function CardGroup(props) {
const {
centered,
children,
className,
content,
doubling,
items,
itemsPerRow,
stackable,
textAlign,
} = props
const classes = cx(
'ui',
useKeyOnly(centered, 'centered'),
useKeyOnly(doubling, 'doubling'),
useKeyOnly(stackable, 'stackable'),
useTextAlignProp(textAlign),
useWidthProp(itemsPerRow),
'cards',
className,
)
const rest = getUnhandledProps(CardGroup, props)
const ElementType = getElementType(CardGroup, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
if (!childrenUtils.isNil(content)) {
return (
<ElementType {...rest} className={classes}>
{content}
</ElementType>
)
}
const itemsJSX = _.map(items, (item) => {
const key = item.key || [item.header, item.description].join('-')
return <Card key={key} {...item} />
})
return (
<ElementType {...rest} className={classes}>
{itemsJSX}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61959
|
TableRow
|
test
|
function TableRow(props) {
const {
active,
cellAs,
cells,
children,
className,
disabled,
error,
negative,
positive,
textAlign,
verticalAlign,
warning,
} = props
const classes = cx(
useKeyOnly(active, 'active'),
useKeyOnly(disabled, 'disabled'),
useKeyOnly(error, 'error'),
useKeyOnly(negative, 'negative'),
useKeyOnly(positive, 'positive'),
useKeyOnly(warning, 'warning'),
useTextAlignProp(textAlign),
useVerticalAlignProp(verticalAlign),
className,
)
const rest = getUnhandledProps(TableRow, props)
const ElementType = getElementType(TableRow, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{_.map(cells, cell => TableCell.create(cell, { defaultProps: { as: cellAs } }))}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61960
|
FeedEvent
|
test
|
function FeedEvent(props) {
const {
content,
children,
className,
date,
extraImages,
extraText,
image,
icon,
meta,
summary,
} = props
const classes = cx('event', className)
const rest = getUnhandledProps(FeedEvent, props)
const ElementType = getElementType(FeedEvent, props)
const hasContentProp = content || date || extraImages || extraText || meta || summary
const contentProps = { content, date, extraImages, extraText, meta, summary }
return (
<ElementType {...rest} className={classes}>
{createShorthand(FeedLabel, val => ({ icon: val }), icon, { autoGenerateKey: false })}
{createShorthand(FeedLabel, val => ({ image: val }), image, { autoGenerateKey: false })}
{hasContentProp && <FeedContent {...contentProps} />}
{children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61961
|
TabPane
|
test
|
function TabPane(props) {
const { active, children, className, content, loading } = props
const classes = cx(useKeyOnly(active, 'active'), useKeyOnly(loading, 'loading'), 'tab', className)
const rest = getUnhandledProps(TabPane, props)
const ElementType = getElementType(TabPane, props)
const calculatedDefaultProps = {}
if (ElementType === Segment) {
calculatedDefaultProps.attached = 'bottom'
}
return (
<ElementType {...calculatedDefaultProps} {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61962
|
ListContent
|
test
|
function ListContent(props) {
const { children, className, content, description, floated, header, verticalAlign } = props
const classes = cx(
useValueAndKey(floated, 'floated'),
useVerticalAlignProp(verticalAlign),
'content',
className,
)
const rest = getUnhandledProps(ListContent, props)
const ElementType = getElementType(ListContent, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{ListHeader.create(header)}
{ListDescription.create(description)}
{content}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61963
|
ButtonOr
|
test
|
function ButtonOr(props) {
const { className, text } = props
const classes = cx('or', className)
const rest = getUnhandledProps(ButtonOr, props)
const ElementType = getElementType(ButtonOr, props)
return <ElementType {...rest} className={classes} data-text={text} />
}
|
javascript
|
{
"resource": ""
}
|
q61964
|
TableCell
|
test
|
function TableCell(props) {
const {
active,
children,
className,
collapsing,
content,
disabled,
error,
icon,
negative,
positive,
selectable,
singleLine,
textAlign,
verticalAlign,
warning,
width,
} = props
const classes = cx(
useKeyOnly(active, 'active'),
useKeyOnly(collapsing, 'collapsing'),
useKeyOnly(disabled, 'disabled'),
useKeyOnly(error, 'error'),
useKeyOnly(negative, 'negative'),
useKeyOnly(positive, 'positive'),
useKeyOnly(selectable, 'selectable'),
useKeyOnly(singleLine, 'single line'),
useKeyOnly(warning, 'warning'),
useTextAlignProp(textAlign),
useVerticalAlignProp(verticalAlign),
useWidthProp(width, 'wide'),
className,
)
const rest = getUnhandledProps(TableCell, props)
const ElementType = getElementType(TableCell, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{Icon.create(icon)}
{content}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61965
|
BreadcrumbDivider
|
test
|
function BreadcrumbDivider(props) {
const { children, className, content, icon } = props
const classes = cx('divider', className)
const rest = getUnhandledProps(BreadcrumbDivider, props)
const ElementType = getElementType(BreadcrumbDivider, props)
if (!_.isNil(icon)) {
return Icon.create(icon, {
defaultProps: { ...rest, className: classes },
autoGenerateKey: false,
})
}
if (!_.isNil(content)) {
return (
<ElementType {...rest} className={classes}>
{content}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? '/' : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61966
|
MessageList
|
test
|
function MessageList(props) {
const { children, className, items } = props
const classes = cx('list', className)
const rest = getUnhandledProps(MessageList, props)
const ElementType = getElementType(MessageList, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? _.map(items, MessageItem.create) : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61967
|
TableFooter
|
test
|
function TableFooter(props) {
const { as } = props
const rest = getUnhandledProps(TableFooter, props)
return <TableHeader {...rest} as={as} />
}
|
javascript
|
{
"resource": ""
}
|
q61968
|
CommentGroup
|
test
|
function CommentGroup(props) {
const { className, children, collapsed, content, minimal, size, threaded } = props
const classes = cx(
'ui',
size,
useKeyOnly(collapsed, 'collapsed'),
useKeyOnly(minimal, 'minimal'),
useKeyOnly(threaded, 'threaded'),
'comments',
className,
)
const rest = getUnhandledProps(CommentGroup, props)
const ElementType = getElementType(CommentGroup, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61969
|
Reveal
|
test
|
function Reveal(props) {
const { active, animated, children, className, content, disabled, instant } = props
const classes = cx(
'ui',
animated,
useKeyOnly(active, 'active'),
useKeyOnly(disabled, 'disabled'),
useKeyOnly(instant, 'instant'),
'reveal',
className,
)
const rest = getUnhandledProps(Reveal, props)
const ElementType = getElementType(Reveal, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61970
|
Segment
|
test
|
function Segment(props) {
const {
attached,
basic,
children,
circular,
className,
clearing,
color,
compact,
content,
disabled,
floated,
inverted,
loading,
placeholder,
padded,
piled,
raised,
secondary,
size,
stacked,
tertiary,
textAlign,
vertical,
} = props
const classes = cx(
'ui',
color,
size,
useKeyOnly(basic, 'basic'),
useKeyOnly(circular, 'circular'),
useKeyOnly(clearing, 'clearing'),
useKeyOnly(compact, 'compact'),
useKeyOnly(disabled, 'disabled'),
useKeyOnly(inverted, 'inverted'),
useKeyOnly(loading, 'loading'),
useKeyOnly(placeholder, 'placeholder'),
useKeyOnly(piled, 'piled'),
useKeyOnly(raised, 'raised'),
useKeyOnly(secondary, 'secondary'),
useKeyOnly(stacked, 'stacked'),
useKeyOnly(tertiary, 'tertiary'),
useKeyOnly(vertical, 'vertical'),
useKeyOrValueAndKey(attached, 'attached'),
useKeyOrValueAndKey(padded, 'padded'),
useTextAlignProp(textAlign),
useValueAndKey(floated, 'floated'),
'segment',
className,
)
const rest = getUnhandledProps(Segment, props)
const ElementType = getElementType(Segment, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61971
|
PlaceholderLine
|
test
|
function PlaceholderLine(props) {
const { className, length } = props
const classes = cx('line', length, className)
const rest = getUnhandledProps(PlaceholderLine, props)
const ElementType = getElementType(PlaceholderLine, props)
return <ElementType {...rest} className={classes} />
}
|
javascript
|
{
"resource": ""
}
|
q61972
|
RevealContent
|
test
|
function RevealContent(props) {
const { children, className, content, hidden, visible } = props
const classes = cx(
'ui',
useKeyOnly(hidden, 'hidden'),
useKeyOnly(visible, 'visible'),
'content',
className,
)
const rest = getUnhandledProps(RevealContent, props)
const ElementType = getElementType(RevealContent, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61973
|
FeedLike
|
test
|
function FeedLike(props) {
const { children, className, content, icon } = props
const classes = cx('like', className)
const rest = getUnhandledProps(FeedLike, props)
const ElementType = getElementType(FeedLike, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{Icon.create(icon, { autoGenerateKey: false })}
{content}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61974
|
Placeholder
|
test
|
function Placeholder(props) {
const { children, className, content, fluid, inverted } = props
const classes = cx(
'ui',
useKeyOnly(fluid, 'fluid'),
useKeyOnly(inverted, 'inverted'),
'placeholder',
className,
)
const rest = getUnhandledProps(Placeholder, props)
const ElementType = getElementType(Placeholder, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61975
|
Accordion
|
test
|
function Accordion(props) {
const { className, fluid, inverted, styled } = props
const classes = cx(
'ui',
useKeyOnly(fluid, 'fluid'),
useKeyOnly(inverted, 'inverted'),
useKeyOnly(styled, 'styled'),
className,
)
const rest = getUnhandledProps(Accordion, props)
return <AccordionAccordion {...rest} className={classes} />
}
|
javascript
|
{
"resource": ""
}
|
q61976
|
PlaceholderImage
|
test
|
function PlaceholderImage(props) {
const { className, square, rectangular } = props
const classes = cx(
useKeyOnly(square, 'square'),
useKeyOnly(rectangular, 'rectangular'),
'image',
className,
)
const rest = getUnhandledProps(PlaceholderImage, props)
const ElementType = getElementType(PlaceholderImage, props)
return <ElementType {...rest} className={classes} />
}
|
javascript
|
{
"resource": ""
}
|
q61977
|
DropdownMenu
|
test
|
function DropdownMenu(props) {
const { children, className, content, direction, open, scrolling } = props
const classes = cx(
direction,
useKeyOnly(open, 'visible'),
useKeyOnly(scrolling, 'scrolling'),
'menu transition',
className,
)
const rest = getUnhandledProps(DropdownMenu, props)
const ElementType = getElementType(DropdownMenu, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61978
|
ListIcon
|
test
|
function ListIcon(props) {
const { className, verticalAlign } = props
const classes = cx(useVerticalAlignProp(verticalAlign), className)
const rest = getUnhandledProps(ListIcon, props)
return <Icon {...rest} className={classes} />
}
|
javascript
|
{
"resource": ""
}
|
q61979
|
Advertisement
|
test
|
function Advertisement(props) {
const { centered, children, className, content, test, unit } = props
const classes = cx(
'ui',
unit,
useKeyOnly(centered, 'centered'),
useKeyOnly(test, 'test'),
'ad',
className,
)
const rest = getUnhandledProps(Advertisement, props)
const ElementType = getElementType(Advertisement, props)
return (
<ElementType {...rest} className={classes} data-text={test}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61980
|
StatisticGroup
|
test
|
function StatisticGroup(props) {
const { children, className, color, content, horizontal, inverted, items, size, widths } = props
const classes = cx(
'ui',
color,
size,
useKeyOnly(horizontal, 'horizontal'),
useKeyOnly(inverted, 'inverted'),
useWidthProp(widths),
'statistics',
className,
)
const rest = getUnhandledProps(StatisticGroup, props)
const ElementType = getElementType(StatisticGroup, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
if (!childrenUtils.isNil(content)) {
return (
<ElementType {...rest} className={classes}>
{content}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{_.map(items, item => Statistic.create(item))}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61981
|
Statistic
|
test
|
function Statistic(props) {
const {
children,
className,
color,
content,
floated,
horizontal,
inverted,
label,
size,
text,
value,
} = props
const classes = cx(
'ui',
color,
size,
useValueAndKey(floated, 'floated'),
useKeyOnly(horizontal, 'horizontal'),
useKeyOnly(inverted, 'inverted'),
'statistic',
className,
)
const rest = getUnhandledProps(Statistic, props)
const ElementType = getElementType(Statistic, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
if (!childrenUtils.isNil(content)) {
return (
<ElementType {...rest} className={classes}>
{content}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{StatisticValue.create(value, {
defaultProps: { text },
autoGenerateKey: false,
})}
{StatisticLabel.create(label, { autoGenerateKey: false })}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61982
|
SegmentGroup
|
test
|
function SegmentGroup(props) {
const { children, className, compact, content, horizontal, piled, raised, size, stacked } = props
const classes = cx(
'ui',
size,
useKeyOnly(compact, 'compact'),
useKeyOnly(horizontal, 'horizontal'),
useKeyOnly(piled, 'piled'),
useKeyOnly(raised, 'raised'),
useKeyOnly(stacked, 'stacked'),
'segments',
className,
)
const rest = getUnhandledProps(SegmentGroup, props)
const ElementType = getElementType(SegmentGroup, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61983
|
TableHeaderCell
|
test
|
function TableHeaderCell(props) {
const { as, className, sorted } = props
const classes = cx(useValueAndKey(sorted, 'sorted'), className)
const rest = getUnhandledProps(TableHeaderCell, props)
return <TableCell {...rest} as={as} className={classes} />
}
|
javascript
|
{
"resource": ""
}
|
q61984
|
Feed
|
test
|
function Feed(props) {
const { children, className, events, size } = props
const classes = cx('ui', size, 'feed', className)
const rest = getUnhandledProps(Feed, props)
const ElementType = getElementType(Feed, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
const eventElements = _.map(events, (eventProps) => {
const { childKey, date, meta, summary, ...eventData } = eventProps
const finalKey = childKey || [date, meta, summary].join('-')
return <FeedEvent date={date} key={finalKey} meta={meta} summary={summary} {...eventData} />
})
return (
<ElementType {...rest} className={classes}>
{eventElements}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61985
|
LabelGroup
|
test
|
function LabelGroup(props) {
const { children, circular, className, color, content, size, tag } = props
const classes = cx(
'ui',
color,
size,
useKeyOnly(circular, 'circular'),
useKeyOnly(tag, 'tag'),
'labels',
className,
)
const rest = getUnhandledProps(LabelGroup, props)
const ElementType = getElementType(LabelGroup, props)
return (
<ElementType {...rest} className={classes}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61986
|
FeedExtra
|
test
|
function FeedExtra(props) {
const { children, className, content, images, text } = props
const classes = cx(
useKeyOnly(images, 'images'),
useKeyOnly(content || text, 'text'),
'extra',
className,
)
const rest = getUnhandledProps(FeedExtra, props)
const ElementType = getElementType(FeedExtra, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
// TODO need a "collection factory" to handle creating multiple image elements and their keys
const imageElements = _.map(images, (image, index) => {
const key = [index, image].join('-')
return createHTMLImage(image, { key })
})
return (
<ElementType {...rest} className={classes}>
{content}
{imageElements}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61987
|
DropdownDivider
|
test
|
function DropdownDivider(props) {
const { className } = props
const classes = cx('divider', className)
const rest = getUnhandledProps(DropdownDivider, props)
const ElementType = getElementType(DropdownDivider, props)
return <ElementType {...rest} className={classes} />
}
|
javascript
|
{
"resource": ""
}
|
q61988
|
FeedSummary
|
test
|
function FeedSummary(props) {
const { children, className, content, date, user } = props
const classes = cx('summary', className)
const rest = getUnhandledProps(FeedSummary, props)
const ElementType = getElementType(FeedSummary, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{createShorthand(FeedUser, val => ({ content: val }), user, { autoGenerateKey: false })}
{content}
{createShorthand(FeedDate, val => ({ content: val }), date, { autoGenerateKey: false })}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61989
|
StepContent
|
test
|
function StepContent(props) {
const { children, className, content, description, title } = props
const classes = cx('content', className)
const rest = getUnhandledProps(StepContent, props)
const ElementType = getElementType(StepContent, props)
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
if (!childrenUtils.isNil(content)) {
return (
<ElementType {...rest} className={classes}>
{content}
</ElementType>
)
}
return (
<ElementType {...rest} className={classes}>
{StepTitle.create(title, { autoGenerateKey: false })}
{StepDescription.create(description, { autoGenerateKey: false })}
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61990
|
Image
|
test
|
function Image(props) {
const {
avatar,
bordered,
centered,
children,
circular,
className,
content,
dimmer,
disabled,
floated,
fluid,
hidden,
href,
inline,
label,
rounded,
size,
spaced,
verticalAlign,
wrapped,
ui,
} = props
const classes = cx(
useKeyOnly(ui, 'ui'),
size,
useKeyOnly(avatar, 'avatar'),
useKeyOnly(bordered, 'bordered'),
useKeyOnly(circular, 'circular'),
useKeyOnly(centered, 'centered'),
useKeyOnly(disabled, 'disabled'),
useKeyOnly(fluid, 'fluid'),
useKeyOnly(hidden, 'hidden'),
useKeyOnly(inline, 'inline'),
useKeyOnly(rounded, 'rounded'),
useKeyOrValueAndKey(spaced, 'spaced'),
useValueAndKey(floated, 'floated'),
useVerticalAlignProp(verticalAlign, 'aligned'),
'image',
className,
)
const rest = getUnhandledProps(Image, props)
const [imgTagProps, rootProps] = partitionHTMLProps(rest, { htmlProps: htmlImageProps })
const ElementType = getElementType(Image, props, () => {
if (
!_.isNil(dimmer) ||
!_.isNil(label) ||
!_.isNil(wrapped) ||
!childrenUtils.isNil(children)
) {
return 'div'
}
})
if (!childrenUtils.isNil(children)) {
return (
<ElementType {...rest} className={classes}>
{children}
</ElementType>
)
}
if (!childrenUtils.isNil(content)) {
return (
<ElementType {...rest} className={classes}>
{content}
</ElementType>
)
}
if (ElementType === 'img') {
return <ElementType {...rootProps} {...imgTagProps} className={classes} />
}
return (
<ElementType {...rootProps} className={classes} href={href}>
{Dimmer.create(dimmer, { autoGenerateKey: false })}
{Label.create(label, { autoGenerateKey: false })}
<img {...imgTagProps} />
</ElementType>
)
}
|
javascript
|
{
"resource": ""
}
|
q61991
|
test
|
function(canvas) {
var context = canvas.getContext('2d'),
devicePixelRatio = window.devicePixelRatio || 1,
backingStorePixelRatio = context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio
|| context.msBackingStorePixelRatio || context.oBackingStorePixelRatio
|| context.backingStorePixelRatio || 1;
return devicePixelRatio / backingStorePixelRatio;
}
|
javascript
|
{
"resource": ""
}
|
|
q61992
|
test
|
function(render, background) {
var cssBackground = background;
if (/(jpg|gif|png)$/.test(background))
cssBackground = 'url(' + background + ')';
render.canvas.style.background = cssBackground;
render.canvas.style.backgroundSize = "contain";
render.currentBackground = background;
}
|
javascript
|
{
"resource": ""
}
|
|
q61993
|
test
|
function(render, body) {
var bodyRender = body.render,
texturePath = bodyRender.sprite.texture,
texture = _getTexture(render, texturePath),
sprite = new PIXI.Sprite(texture);
sprite.anchor.x = body.render.sprite.xOffset;
sprite.anchor.y = body.render.sprite.yOffset;
return sprite;
}
|
javascript
|
{
"resource": ""
}
|
|
q61994
|
test
|
function(render, body) {
var bodyRender = body.render,
options = render.options,
primitive = new PIXI.Graphics(),
fillStyle = Common.colorToNumber(bodyRender.fillStyle),
strokeStyle = Common.colorToNumber(bodyRender.strokeStyle),
strokeStyleIndicator = Common.colorToNumber(bodyRender.strokeStyle),
strokeStyleWireframe = Common.colorToNumber('#bbb'),
strokeStyleWireframeIndicator = Common.colorToNumber('#CD5C5C'),
part;
primitive.clear();
// handle compound parts
for (var k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) {
part = body.parts[k];
if (!options.wireframes) {
primitive.beginFill(fillStyle, 1);
primitive.lineStyle(bodyRender.lineWidth, strokeStyle, 1);
} else {
primitive.beginFill(0, 0);
primitive.lineStyle(1, strokeStyleWireframe, 1);
}
primitive.moveTo(part.vertices[0].x - body.position.x, part.vertices[0].y - body.position.y);
for (var j = 1; j < part.vertices.length; j++) {
primitive.lineTo(part.vertices[j].x - body.position.x, part.vertices[j].y - body.position.y);
}
primitive.lineTo(part.vertices[0].x - body.position.x, part.vertices[0].y - body.position.y);
primitive.endFill();
// angle indicator
if (options.showAngleIndicator || options.showAxes) {
primitive.beginFill(0, 0);
if (options.wireframes) {
primitive.lineStyle(1, strokeStyleWireframeIndicator, 1);
} else {
primitive.lineStyle(1, strokeStyleIndicator);
}
primitive.moveTo(part.position.x - body.position.x, part.position.y - body.position.y);
primitive.lineTo(((part.vertices[0].x + part.vertices[part.vertices.length-1].x) / 2 - body.position.x),
((part.vertices[0].y + part.vertices[part.vertices.length-1].y) / 2 - body.position.y));
primitive.endFill();
}
}
return primitive;
}
|
javascript
|
{
"resource": ""
}
|
|
q61995
|
test
|
function(body, options) {
options = options || {};
// init required properties (order is important)
Body.set(body, {
bounds: body.bounds || Bounds.create(body.vertices),
positionPrev: body.positionPrev || Vector.clone(body.position),
anglePrev: body.anglePrev || body.angle,
vertices: body.vertices,
parts: body.parts || [body],
isStatic: body.isStatic,
isSleeping: body.isSleeping,
parent: body.parent || body
});
Vertices.rotate(body.vertices, body.angle, body.position);
Axes.rotate(body.axes, body.angle);
Bounds.update(body.bounds, body.vertices, body.velocity);
// allow options to override the automatically calculated properties
Body.set(body, {
axes: options.axes || body.axes,
area: options.area || body.area,
mass: options.mass || body.mass,
inertia: options.inertia || body.inertia
});
// render properties
var defaultFillStyle = (body.isStatic ? '#2e2b44' : Common.choose(['#006BA6', '#0496FF', '#FFBC42', '#D81159', '#8F2D56'])),
defaultStrokeStyle = '#000';
body.render.fillStyle = body.render.fillStyle || defaultFillStyle;
body.render.strokeStyle = body.render.strokeStyle || defaultStrokeStyle;
body.render.sprite.xOffset += -(body.bounds.min.x - body.position.x) / (body.bounds.max.x - body.bounds.min.x);
body.render.sprite.yOffset += -(body.bounds.min.y - body.position.y) / (body.bounds.max.y - body.bounds.min.y);
}
|
javascript
|
{
"resource": ""
}
|
|
q61996
|
createPages
|
test
|
async function createPages({ actions, graphql }) {
const retrieveMarkdownPages = () =>
graphql(`
{
allMarkdownRemark(limit: 1000) {
edges {
node {
frontmatter {
path
}
}
}
}
}
`)
const exampleTemplate = path.resolve(`src/templates/exampleTemplate.tsx`)
const docTemplate = path.resolve(`src/templates/docTemplate.tsx`)
const result = await retrieveMarkdownPages()
if (result.errors) {
console.error('graphql error', result.errors)
throw new Error('Error invoking graphql for pages')
}
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
const {
frontmatter: { path: pagePath },
} = node
const category = (pagePath || '/').split('/').filter(t => !!t)[0]
const isExample = category === 'examples'
console.log(`create page for ${pagePath} - type is ${category}`)
actions.createPage({
path: pagePath,
component: isExample ? exampleTemplate : docTemplate,
context: {}, // additional data can be passed via context
})
})
}
|
javascript
|
{
"resource": ""
}
|
q61997
|
isWindow
|
test
|
function isWindow(val) {
if (typeof val !== "object") {
return false;
}
const wrapper = idlUtils.wrapperForImpl(val);
if (typeof wrapper === "object") {
return wrapper === wrapper._globalProxy;
}
// `val` may be either impl or wrapper currently, because webidl2js currently unwraps Window objects (and their global
// proxies) to their underlying EventTargetImpl during conversion, which is not what we want. But at the same time,
// some internal usage call this constructor with the actual global proxy.
return isWindow(idlUtils.implForWrapper(val));
}
|
javascript
|
{
"resource": ""
}
|
q61998
|
normalizeEventHandlerOptions
|
test
|
function normalizeEventHandlerOptions(options, defaultBoolKeys) {
const returnValue = {};
// no need to go further here
if (typeof options === "boolean" || options === null || typeof options === "undefined") {
returnValue.capture = Boolean(options);
return returnValue;
}
// non objects options so we typecast its value as "capture" value
if (typeof options !== "object") {
returnValue.capture = Boolean(options);
// at this point we don't need to loop the "capture" key anymore
defaultBoolKeys = defaultBoolKeys.filter(k => k !== "capture");
}
for (const key of defaultBoolKeys) {
returnValue[key] = Boolean(options[key]);
}
return returnValue;
}
|
javascript
|
{
"resource": ""
}
|
q61999
|
sammary
|
test
|
function sammary() {
const nodeFn = function ({ parentPaths, lang, item, isDir, result }) {
const navTitle = generateNavTitle({ parentPaths, item, sign: isDir ? '-' : '*', lang });
result.push(navTitle);
};
langs.forEach(dir => {
const SUMMARY = 'SUMMARY.md';
const targetFile = path.join(docsDir, `${dir}/${SUMMARY}`);
const result = walk({
catalog: docConfig.catalog,
lang: dir,
result: [],
parentPaths: [],
fn: nodeFn
});
if (result && result.length) {
result.unshift('# whistle\n');
fs.writeFileSync(targetFile, result.join('\n'));
}
});
}
|
javascript
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.