Best JavaScript code snippet using playwright-internal
GridDesigner.js
Source:GridDesigner.js
1/*2 * Copyright (C) 2012 VMware, Inc. All rights reserved.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * http://www.apache.org/licenses/LICENSE-2.08 * Unless required by applicable law or agreed to in writing, software9 * distributed under the License is distributed on an "AS IS" BASIS,10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11 * See the License for the specific language governing permissions and12 * limitations under the License.13 */14dojo.declare("GridDesigner", wm.Page, {15 start: function() {16 wm.typeManager.types.gridDefinitionType.fields.field.include = ["update"];17 this._editors = [];18 wm.forEachWidget(this.root, dojo.hitch(this, function(w) {19 if (w instanceof wm.AbstractEditor) {20 this._editors.push(w);21 }22 }));23 },24 updateFormatterList: function(){25 this.fullFormattersVar.setData(this.formattersVar);26 dojo.forEach(getAllEventsInCode(), dojo.hitch(this, function(f){27 if (f.match(/Format$/))28 this.fullFormattersVar.addItem({name:f, dataValue:f}); 29 }));30 this.fullFormattersVar.addItem({name:studio.getDictionaryItem("wm.DojoGrid.ADD_FORMATTER"), dataValue:"- Add Formatter"});31 },32 updateDataSets: function() {33 var list = [{dataValue:""}];34 wm.listMatchingComponentIds([studio.page, studio.application], function(c) {35 if (c instanceof wm.Variable && c.isList && c.name && c.name.indexOf("_") != 0) {36 list.push({dataValue: c.getId()});37 }38 });39 this.liveSourceVar.setData(list);40 },41 setGrid: function(inGrid) {42 this.currentGrid = inGrid;43 this.editorPanels.setShowing(inGrid instanceof wm.DojoGrid); // hide if its wm.List44 this.currentDataSet = inGrid.dataSet;45 this.initialColumns = inGrid.columns46 var columns = dojo.clone(inGrid.columns);47 var mobileIndex = -1;48 for (var i = 0; i < columns.length; i++) {49 if (!columns[i].mobileColumn) {50 columns[i].mobileColumn = false;51 } else52 mobileIndex = i;53 }54 if (mobileIndex == -1) {55 columns.push({show: true,56 field: "MOBILE COLUMN",57 title: "-",58 width: "100%",59 align: "left",60 expression: "",61 mobileColumn: true});62 mobileIndex = columns.length-1;63 }64 this.columnsVar.setData(columns);65 this.mobileColumn = this.columnsVar.getItem(mobileIndex);66 this.regenerateMobileColumn();67 this.updateFormatterList();68 this.updateDataSets();69 },70 regenerateMobileColumn: function() {71 if (!this.mobileColumn || this.mobileColumn.getValue("isCustomField")) return;72 var mobileExpr = "";73 var count = this.columnsVar.getCount();74 for (var i = 0; i < count; i++) {75 var column = this.columnsVar.getItem(i).getData();76 if (!column.mobileColumn && column.show) {77 if (column.expression) {78 // don't even TRY to handle this79 } else {80 var value = "\${" + column.field + "}";81 var formatProps = column.formatProps ? dojo.toJson(column.formatProps) : "{}";82 if (column.formatFunc) {83 switch(column.formatFunc) {84 case "wm_date_formatter": 85 case 'Date (WaveMaker)': 86 case 'wm_localdate_formatter':87 case 'Local Date (WaveMaker)': 88 value = "wm.DojoGrid.prototype.dateFormatter(" + formatProps + ", null,null,null," + value +")";89 break;90 case 'wm_number_formatter':91 case 'Number (WaveMaker)': 92 value = "wm.DojoGrid.prototype.numberFormatter(" + formatProps + ", null,null,null," + value +")";93 break;94 case 'wm_currency_formatter':95 case 'Currency (WaveMaker)': 96 value = "wm.DojoGrid.prototype.currencyFormatter(" + formatProps + ", null,null,null," + value +")";97 break;98 case 'wm_image_formatter':99 case 'Image (WaveMaker)': 100 value = "wm.DojoGrid.prototype.imageFormatter(" + formatProps + ", null,null,null," + value +")";101 break;102 case 'wm_link_formatter':103 case 'Link (WaveMaker)': 104 value = "wm.DojoGrid.prototype.linkFormatter(" + formatProps + ", null,null,null," + value +")";105 break;106 case 'wm_button_formatter':107 value = null;108 break;109 }110 }111 if (value) {112 if (!mobileExpr) {113 mobileExpr = "\"<div class='MobileRowTitle'>" + wm.capitalize(column.title) + ": \" + " + value + " + \"</div>\"\n";114 } else {115 mobileExpr += "+ \"<div class='MobileRow'>" + wm.capitalize(column.title) + ": \" + " + value + " + \"</div>\"\n";116 }117 }118 }119 }120 }121 if (studio.currentDeviceType != "phone") 122 this.mobileColumn.beginUpdate();123 this.mobileColumn.setValue("expression", mobileExpr);124 if (studio.currentDeviceType != "phone") 125 this.mobileColumn.endUpdate();126 },127 getColumnByField: function(inName) {128 for (var i = 0; i < this.currentGrid.columns.length; i++) {129 if (this.currentGrid.columns[i].field == inName)130 return this.currentGrid.columns[i];131 }132 },133 moveUp: function(inSender) {134 var item = this.grid.selectedItem.getData();135 var selectedIndex = this.grid.getSelectedIndex();136 if (selectedIndex <= 0) return;137 this.columnsVar.beginUpdate();138 this.columnsVar.removeItem(selectedIndex);139 this.columnsVar.addItem(item, selectedIndex-1);140 this.columnsVar.endUpdate();141 this.columnsVar.notify();142 this.updateGrid();143 },144 moveDown: function(inSender) {145 var item = this.grid.selectedItem.getData();146 var selectedIndex = this.grid.getSelectedIndex();147 if (selectedIndex == -1 || selectedIndex >= this.columnsVar.getCount()) return;148 this.columnsVar.beginUpdate();149 this.columnsVar.removeItem(selectedIndex);150 this.columnsVar.addItem(item, selectedIndex+1);151 this.columnsVar.endUpdate();152 this.columnsVar.notify();153 this.updateGrid(); 154 },155 addButtonClick: function(inSender) {156 try {157 var newName = "customField";158 for (var i = 0; this.getColumnByField(newName + i); i++) {}159 160 app.prompt("Enter an ID/fieldName for this column; this must be a unique name",161 newName + i,162 dojo.hitch(this, function(inResult) {163 if (inResult && !this.getColumnByField(inResult)) {164 this.grid.deselectAll();165 this.grid.selectedItem.setDataSet(null);166 this.columnsVar.addItem({field: inResult,167 width: "100%",168 title: wm.capitalize(inResult),169 align: "left",170 isCustomField: true,171 show: true});172 this.updateGrid();173 window.setTimeout(dojo.hitch(this, function() {174 this.grid.select(this.grid.getRowCount() - 1);175 }), 1000);176 }177 }));178 } catch(e) {179 console.error('ERROR IN addButtonClick: ' + e); 180 } 181 },182 deleteButtonClick: function(inSender) {183 var row = this.grid.getSelectedIndex() ;184 if (row == -1) return;185 this.columnsVar.removeItem(row);186 this.updateGrid();187 window.setTimeout(dojo.hitch(this, function() {188 this.grid.select(0);189 }), 10);190 },191 onColumnSelect: function(inSender) {192 },193 changeItem: function(inName, inValue, optionalRowIndex) {194 if (this.columnsVar.isEmpty()) return;195 var row = (optionalRowIndex === undefined) ? this.grid.getSelectedIndex() : optionalRowIndex;196 if (row == -1) return;197 var item = this.columnsVar.getItem(row);198 if (item.getValue("mobileColumn") && inName == "expression") {199 item.beginUpdate();200 item.setValue("isCustomField", true);201 item.endUpdate();202 }203 if (item.getValue(inName) != inValue) {204 item.beginUpdate(); // we don't need to regenerate the grid when this item changes205 item.setValue(inName, inValue);206 item.endUpdate();207 if (item.getValue("mobileColumn") == false) {208 this.regenerateMobileColumn();209 }210 this.updateGrid(row);211 return true;212 }213 return false;214 },215 updateGrid: function() {216 this.regenerateMobileColumn();217 var columns = this.columnsVar.getData();218 for (var i = 0; i < columns.length; i++) {219 var col = columns[i];220 if (col.editorProps) {221 for (var name in col.editorProps) {222 if (col.editorProps[name] === null)223 delete col.editorProps[name];224 }225 }226 if (col.constraints) {227 for (var name in col.constraints) {228 if (col.constraints[name] === null)229 delete col.constraints[name];230 }231 }232 if (col.formatProps) {233 for (var name in col.formatProps) {234 if (col.formatProps[name] === null)235 delete col.formatProps[name];236 }237 }238 }239 this.currentGrid.set_columns(columns);240 },241 onTitleChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {242 if (!inSetByCode) {243 this.changeItem("title", inDataValue);244 }245 },246 onWidthChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {247 if (!inSetByCode) {248 var displayValue = this.widthSizeEditor.getDisplayValue();249 var w;250 if (displayValue.indexOf("p") != -1 ||251 displayValue.indexOf("%") != -1) {252 w = displayValue;253 this.widthSizeEditor.setDataValue(parseInt(displayValue));254 this.widthTypeEditor.setDataValue(displayValue.indexOf("p") != -1 ? "px" : "%");255 } else {256 w = displayValue + (this.widthTypeEditor.getDataValue() || "%");257 }258 this.changeItem("width", w);259 }260 },261 onAlignChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {262 if (!inSetByCode) {263 this.changeItem("align", inDataValue);264 }265 },266 onFormatChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {267 if (!inSetByCode) {268 var isCustom = false;269 if (inDataValue == "- Add Formatter") {270 inDataValue = wm.getValidJsName(this.currentGrid.name + wm.getValidJsName(wm.capitalize(this.grid.selectedItem.getValue("field"))) + 'Format');271 isCustom = true;272 }273 if (this.changeItem("formatFunc", inDataValue)) {274 var row = this.grid.getSelectedIndex();275 var item = this.columnsVar.getItem(row);276 var formatProps = item.getValue("formatProps");277 formatProps.beginUpdate();278 formatProps.clearData();279 formatProps.endUpdate();280 formatProps = this.form.dataSet.getValue("formatProps");281 formatProps.beginUpdate();282 formatProps.clearData();283 formatProps.endUpdate();284 this.formatSubForm.setDataSet(formatProps);285 }286 switch(inDataValue) {287 case "wm_currency_formatter":288 this.currencyLayer.activate();289 break;290 case "wm_number_formatter":291 this.numberLayer.activate();292 break;293 case "wm_image_formatter":294 this.imageLayer.activate();295 break;296 case "wm_button_formatter":297 this.buttonLayer.activate();298 break;299 case "wm_link_formatter":300 this.linkLayer.activate();301 break;302 case "wm_date_formatter":303 this.dateLayer.activate();304 if (!this.dateFormatLength.getDataValue())305 this.dateFormatLength.setDataValue("short");306 break;307 default:308 this.formatBlankLayer.activate();309 if (isCustom) {310 eventEdit(this.currentGrid, "_formatterSignature", inDataValue, true);311 this.owner.owner.hide();312 }313 }314 }315 },316 onEditFieldChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {317 if (!inSetByCode) {318 if (this.changeItem("fieldType", inDataValue)) {319 var row = this.grid.getSelectedIndex();320 var item = this.columnsVar.getItem(row);321 var editorProps = item.getValue("editorProps");322 editorProps.beginUpdate();323 editorProps.clearData();324 editorProps.endUpdate();325 editorProps = this.form.dataSet.getValue("editorProps");326 editorProps.beginUpdate();327 editorProps.clearData();328 editorProps.endUpdate();329 var constraints = item.getValue("constraints");330 constraints.beginUpdate();331 constraints.clearData();332 constraints.endUpdate();333 constraints = this.form.dataSet.getValue("constraints");334 constraints.beginUpdate();335 constraints.clearData();336 constraints.endUpdate();337 this.editorSelectLayerSubForm.setDataSet(editorProps);338 this.editorComboBoxLayerSubForm.setDataSet(editorProps);339 this.editorNumberLayerSubForm.setDataSet(constraints);340 this.editorDateLayerSubForm.setDataSet(constraints);341 this.editorTextLayerSubForm.setDataSet(editorProps);342 }343 switch(inDataValue) {344 case "dojox.grid.cells._Widget":345 this.editorTextLayer.activate();346 break;347 case "dojox.grid.cells.NumberTextBox":348 this.editorNumberLayer.activate();349 break;350 case "dojox.grid.cells.DateTextBox":351 this.editorDateLayer.activate();352 break;353 case "dojox.grid.cells.TimeTextBox":354 this.editorTimeLayer.activate();355 break;356 case "dojox.grid.cells.Checkbox":357 this.editorCheckboxLayer.activate();358 break;359 case "dojox.grid.cells.ComboBox":360 this.editorComboBoxLayer.activate();361 break;362 case "dojox.grid.cells.Select":363 this.editorSelectLayer.activate();364 break;365 default:366 this.editorPropBlankLayer.activate();367 }368 }369 },370 onDisplayExprChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {371 if (!inSetByCode) {372 this.changeItem("expression", inDataValue);373 }374 },375 onBackExprChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {376 if (!inSetByCode) {377 this.changeItem("backgroundColor", inDataValue);378 }379 },380 onColorExprChange:function(inSender, inDisplayValue, inDataValue, inSetByCode) {381 if (!inSetByCode) {382 this.changeItem("textColor", inDataValue);383 }384 },385 onCancelClick: function() {386 this.currentGrid.set_columns(this.initialColumns);387 this.owner.owner.hide();388 },389 onOkClick: function() {390 this.owner.owner.hide();391 },392 onCellEdited: function(inSender, inValue, rowId, fieldId) {393 this.updateGrid(rowId);394 },395 /* Currency Formatter Changes */396 onCurrencyTypeChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {397 if (!inSetByCode) {398 this.changeItem("formatProps.currency", inDataValue);399 }400 },401 onCurrencyDijitsChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {402 if (!inSetByCode) {403 this.changeItem("formatProps.dijits", inDataValue);404 }405 },406 onCurrencyRoundChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {407 if (!inSetByCode) {408 this.changeItem("formatProps.round", inDataValue);409 }410 },411 onDateLengthChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {412 if (!inSetByCode) {413 this.changeItem("formatProps.formatLength", inDataValue);414 }415 },416 onDatePatternChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {417 if (!inSetByCode) {418 this.changeItem("formatProps.datePattern", inDataValue);419 }420 },421 onTimePatternChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {422 if (!inSetByCode) {423 this.changeItem("formatProps.timePattern", inDataValue);424 }425 },426 onUseLocalTimeChange:function(inSender, inDisplayValue, inDataValue, inSetByCode) {427 if (!inSetByCode) {428 this.changeItem("formatProps.useLocalTime", inDataValue);429 }430 },431 onDateTimeChange:function(inSender, inDisplayValue, inDataValue, inSetByCode) {432 if (!inSetByCode) {433 this.changeItem("formatProps.dateType", inDataValue);434 }435 },436 onNumberTypeChange:function(inSender, inDisplayValue, inDataValue, inSetByCode) {437 if (!inSetByCode) {438 this.changeItem("formatProps.numberType", inDataValue);439 }440 },441 onNumberDijitsChange:function(inSender, inDisplayValue, inDataValue, inSetByCode) {442 if (!inSetByCode) {443 this.changeItem("formatProps.dijits", inDataValue);444 }445 },446 onNumberRoundChange:function(inSender, inDisplayValue, inDataValue, inSetByCode) {447 if (!inSetByCode) {448 this.changeItem("formatProps.round", inDataValue);449 }450 },451 onLinkPrefixChange:function(inSender, inDisplayValue, inDataValue, inSetByCode) {452 if (!inSetByCode) {453 this.changeItem("formatProps.prefix", inDataValue);454 }455 },456 onLinkPostfixChange:function(inSender, inDisplayValue, inDataValue, inSetByCode) {457 if (!inSetByCode) {458 this.changeItem("formatProps.postfix", inDataValue);459 }460 },461 onTargetChange:function(inSender, inDisplayValue, inDataValue, inSetByCode) {462 if (!inSetByCode) {463 this.changeItem("formatProps.target", inDataValue);464 }465 },466 onImageWidthChange:function(inSender, inDisplayValue, inDataValue, inSetByCode) {467 if (!inSetByCode) {468 this.changeItem("formatProps.width", inDataValue);469 }470 },471 onImageHeightChange:function(inSender, inDisplayValue, inDataValue, inSetByCode) {472 if (!inSetByCode) {473 this.changeItem("formatProps.height", inDataValue);474 }475 },476 onButtonClassChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {477 if (!inSetByCode) {478 this.changeItem("formatProps.buttonclass", inDataValue);479 }480 },481 onRegexChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {482 if (!inSetByCode) {483 this.changeItem("editorProps.regExp", inDataValue);484 }485 },486 onRequiredChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {487 if (!inSetByCode) {488 this.changeItem("editorProps.required", inDataValue);489 }490 },491 onInvalidChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {492 if (!inSetByCode) {493 this.changeItem("editorProps.invalidMessage", inDataValue);494 }495 },496 onOptionsChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {497 if (!inSetByCode) {498 this.changeItem("editorProps.options", inDataValue);499 }500 },501 onDataSetChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {502 if (!inSetByCode) {503 this.changeItem("editorProps.selectDataSet", inDataValue);504 var c = studio.page.getValueById(inDataValue);505 var options = [];506 if (c)507 var type = wm.typeManager.getType(c.type);508 if (type) {509 var fields = type.fields;510 }511 if (fields) {512 for (var fieldName in fields) {513 var fieldDef = fields[fieldName];514 if (!wm.typeManager.isStructuredType(fieldDef.type))515 options.push(fieldName);516 }517 }518 this.comboBoxDisplayFieldEditor.setOptions(options.join(","));519 }520 },521 onDisplayFieldChange:function(inSender, inDisplayValue, inDataValue, inSetByCode) {522 if (!inSetByCode) {523 this.changeItem("editorProps.displayField", inDataValue);524 }525 },526 onMaximumChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {527 if (!inSetByCode) {528 this.changeItem("constraints.max", inDataValue);529 }530 },531 onMinimumChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {532 if (!inSetByCode) {533 this.changeItem("constraints.min", inDataValue);534 }535 },536 onCustomCssClassChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {537 if (!inSetByCode) {538 this.changeItem("cssClass", inDataValue);539 }540 },541 onRenderData: function() {542 this.grid.dojoObj.canSort = function() {return false;}543 },544 _end: 0...
docs.js
Source:docs.js
...25 name: `Discord.js Docs (${version})`,26 icon_url: `https://cdn.discordapp.com/icons/222078108977594368/bc226f09db83b9176c64d923ff37010b.webp`27 }28 }; //data for embed29 function formatProps(props) {30 var names = [];31 for(var i=0;i<props.length;i++) {32 names.push(props[i].name);33 }34 return names.join(" ");35 }36 function formatMethods(methods) {37 var names = [];38 for(var i=0;i<methods.length;i++) {39 names.push(methods[i].name);40 }41 return names.join(" ");42 }43 function formatEvents(events) {44 var names = [];45 for(var i=0;i<events.length;i++) {46 names.push(events[i].name);47 }48 return names.join(" ");49 }50 function formatReturn(input) {51 var string = "";52 for(var i=0;i<input.length;i++) {53 string += input[i].join("");54 }55 return string;56 }57 function makeOptional(input) {58 return `[${input}]`59 }60 function getLower(msg,prop,query,type) {61 for(var class_key in prop) { //Loop the class62 for(var class_lowerkey in prop[class_key]) { //Loop all the classes63 //if(prop[class_key] === "meta");64 var subClass = prop[class_key][class_lowerkey];65 if(subClass.name && subClass.name.toLowerCase() === query[1]) { //If looped class's name === query[1]66 67 var outputFields = [];68 if(subClass.type) outputFields.push({name:"Type",value:`\`\`${formatReturn(subClass.type[0])}\`\``}); //for Client69 if(subClass.returns && typeof subClass.returns == "array") outputFields.push({name:"Returns",value:formatReturn(subClass.returns[0])});70 subClass.description = subClass.description.replace(/<.+>/g, '').replace(/\n/g,' ').trim();71 72 if(subClass.params) { //If there is parameters, loop them and list them.73 var params = "";74 for(var d=0;d<subClass.params.length;d++) { 75 if(subClass.params[d].optional) params += "``" + makeOptional(subClass.params[d].name) + ": "; //Is optional? [optional] not-optional76 if(!subClass.params[d].optional) params += "``" + subClass.params[d].name + ": ";77 var types = [];78 for(var t=0;t<subClass.params[d].type.length;t++) { //put in array to easily join them79 types.push(subClass.params[d].type[t][0]);80 }81 params += types.join(" | ") + "``\n";82 params += subClass.params[d].description + "\n\n";83 84 85 }86 outputFields.push({name:"Parameters",value:params}); 87 }88 if(subClass.returns && typeof(subClass.returns === 'object')) { 89 if(subClass.returns.types) {90 outputFields.push({name:"Returns",value:`${subClass.returns.description.replace(/<.+>/g, '').replace(/\n/g,' ')}\n\`\`=> ${formatReturn(subClass.returns.types[0])}\`\``});91 }else {92 outputFields.push({name:"Returns",value:`\`\`${formatReturn(subClass.returns[0])}\`\``});93 }94 95 }96 if(subClass.examples && subClass.examples.length > 0) outputFields.push({name:'Example',value:`\`\`\`js\n${subClass.examples[0]}\`\`\``})97 var outputData = {98 title:`${prop.name}#${subClass.name}`,99 url:`https://discord.js.org/#/docs/main/${version}/${type}/${prop.name}?scrollTo=${subClass.name}`, 100 description:subClass.description,101 fields:outputFields102 }103 104 105 Object.assign(outputData,defaultOutput); //merge defaultOutput object with outputData106 return msg.edit({embed: outputData}).catch(err => {107 msg.edit(`An error occurred while sending: \`\`${err.message}\`\``);108 console.log(err);109 });110 }111 112 }113 114 }115 return msg.edit(`Couldn't find anything for \`\`${query[0]}${(query[1] ? `#${query[1]}`:'')}\`\``); //dont even know where to put this116 }117 const cache = docsCache[version].data;118 //instead of looping object or something, just manually doing it 119 for(let i=0;i<cache.classes.length;i++) {120 for(var key in cache.classes[i]) {121 if(cache.classes[i].name.toLowerCase() === query[0]){ //if classes's name === query122 var prop = cache.classes[i];123 if(query[1]) {124 return getLower(msg,prop,query,'class');125 } 126 127 var outputFields = [];128 if(prop.props) outputFields.push({name:"Properties",value:'``' + formatProps(prop.props) + '``'})129 if(prop.methods) outputFields.push({name:"Methods",value:'``' + formatProps(prop.methods) + '``'})130 if(prop.events) outputFields.push({name:"Events",value:'``' + formatProps(prop.events) + '``'})131 var outputData = {132 title:`**${prop.name} ` + ((prop.extends) ? `(extends ${prop.extends.join(" ,")})` : '') + `**`,133 url:`https://discord.js.org/#/docs/main/${version}/class/${prop.name}`,134 description:prop.description,135 fields:outputFields136 }137 Object.assign(outputData,defaultOutput); //merge defaultOutput object with outputData138 return msg.edit({embed: outputData}).catch(err => {139 msg.edit(`An error occurred while sending: \`\`${err.message}\`\``);140 });141 }142 }143 }144 for(let i=0;i<cache.interfaces.length;i++) {145 for(var key in cache.interfaces[i]) {146 if(cache.interfaces[i].name.toLowerCase() === query[0]){ //if interfaces's name === query147 var prop = cache.interfaces[i];148 if(query[1]) {149 return getLower(msg,prop,query,'interfaces');150 } 151 var prop = cache.interfaces[i];152 var outputFields = [];153 if(prop.props) outputFields.push({name:"Properties",value:'``' + formatProps(prop.props) + '``'})154 if(prop.methods) outputFields.push({name:"Methods",value:'``' + formatProps(prop.methods) + '``'})155 if(prop.events) outputFields.push({name:"Events",value:'``' + formatProps(prop.events) + '``'})156 var outputData = {157 title:`**${prop.name} ` + ((prop.extends) ? `(extends ${prop.extends.join(" ,")}))` : '') + `**`,158 url:`https://discord.js.org/#/docs/${version}/interfaces/${prop.name}`,159 description:prop.description,160 fields:outputFields161 }162 Object.assign(outputData,defaultOutput); //merge defaultOutput object with outputData163 return msg.edit({embed: outputData}).catch(err => {164 msg.edit(`An error occurred while sending: \`\`${err.message}\`\``);165 })166 }167 }168 }169 for(let i=0;i<cache.typedefs.length;i++) {170 for(var key in cache.typedefs[i]) {171 if(cache.typedefs[i].name.toLowerCase() === query[0]){ //if typedefs's name === query172 var prop = cache.typedefs[i];173 if(query[1]) {174 if(prop.props) { //Loop all the porperties of the typedef175 for(var d=0;d<prop.props.length;d++) {176 if(prop.props[d].name.toLowerCase() === query[1]) {177 var outputData = {178 title:`${prop.name}#${prop.props[d].name}`,179 url:`https://discord.js.org/#/docs/main/${version}/typedef/${prop.name}?scrollTo=${prop.props[d].name}`,180 description:prop.props[d].description,181 fields:[182 {183 name:"Type",184 value:"``" + formatReturn(prop.props[d].type[0]) + "``"185 }186 ]187 }188 Object.assign(outputData,defaultOutput); //merge defaultOutput object with outputData189 return msg.edit({embed: outputData}).catch(err => {190 msg.edit(`An error occurred while sending: \`\`${err.message}\`\``);191 })192 }193 }194 }else return msg.edit(`There is no properties for \`\`${query[0]}\`\``);195 return msg.edit(`Couldn't find anything for \`\`${query[0]}${(query[1] ? `#${query[1]}`:'')}\`\``);196 } 197 var prop = cache.typedefs[i];198 var outputFields = [];199 if(prop.props) outputFields.push({name:"Properties",value:'``' + formatProps(prop.props) + '``'})200 if(prop.methods) outputFields.push({name:"Methods",value:'``' + formatProps(prop.methods) + '``'})201 if(prop.events) outputFields.push({name:"Events",value:'``' + formatProps(prop.events) + '``'})202 var outputData = {203 title:`**${prop.name} ` + ((prop.extends) ? `(extends ${prop.extends.join(" ,")}))` : '') + `**`,204 url:`https://discord.js.org/#/docs/main/${version}/typedef/${prop.name}`,205 description:prop.description,206 fields:outputFields207 }208 Object.assign(outputData,defaultOutput); //merge defaultOutput object with outputData209 return msg.edit({embed: outputData}).catch(err => {210 msg.edit(`An error occurred while sending: \`\`${err.message}\`\``);211 })212 }213 }214 }215 ...
JSXLoader.js
Source:JSXLoader.js
...109 } else if (item.endsWith('/>')) {110 // å¦ææ¯èªéåæ ç¾111 queue[queueIndex].children.push({112 type,113 props: formatProps(props),114 children: []115 })116 } else if (item.startsWith('</')) {117 // æ¯å°¾æ ç¾118 queueIndex--119 queue.pop()120 } else {121 // æ¯å¤´æ ç¾122 const createElement = {123 type,124 props: formatProps(props),125 children: []126 }127 queue[queueIndex++].children.push(createElement)128 queue.push(createElement)129 }130 }131 if (queue.length > 1) {132 throw new SyntaxError('åå¨æªéåçæ ç¾')133 }134 // 深度éåéåç»æçææç»ä»£ç 135 const dfs = item => {136 if (item.type === TEXT_LABEL_NAME) {137 // 纯ææ¬ç´æ¥è¿åæåå
容138 return item.props...
FormatterService.js
Source:FormatterService.js
1import React from 'react';2import cloneDeep from 'lodash/cloneDeep';3import size from 'lodash/size';4import isPlainObject from 'lodash/isPlainObject';5import isFunction from 'lodash/isFunction';6import { t } from '../../../../helpers/export/util';7import { replacePlaceholders, valueOrNull } from '../util';8import formatterRegistry from './registry';9import CellType from './CellType';10import Popper from '../../../common/Popper';11/**12 * @typedef {Object} FormatterConfig13 *14 * @typedef {Object} Formatter15 * @field {String} type16 * @field {FormatterInnerConfig} config17 *18 * @typedef {Object} FormatterServiceProps19 * @field {Any} cell - Cell data20 * @field {Object} row - Current row data21 * @field {Number} rowIndex - Row index22 * @field {Object} column - Column config23 *24 * @typedef {FormatterServiceProps & {config: FormatterConfig}} FormatterProps25 */26class FormatterService {27 static get errorMessage() {28 return `#${t('error').toUpperCase()}`;29 }30 static PopperWrapper(props) {31 return (32 <Popper33 showAsNeeded34 icon="icon-question"35 popupClassName="formatter-popper"36 text={props.text}37 contentComponent={props.contentComponent}38 >39 {props.children}40 </Popper>41 );42 }43 /**44 * @param {FormatterServiceProps} props45 * @param {Formatter} formatter46 * @return {React.ReactNode}47 */48 static format(props = {}, formatter = {}) {49 try {50 return FormatterService._formatImpl(props, formatter);51 } catch (e) {52 console.error('[FormattersService.format] error', props, formatter, e);53 return FormatterService.errorMessage;54 }55 }56 static _formatImpl(props = {}, formatter = {}) {57 const { row, cell } = props;58 const { type, config } = formatter;59 if (!type) {60 console.error('[FormattersService.format] empty formatter type', formatter);61 return FormatterService.errorMessage;62 }63 let modifiedConfig = cloneDeep(config);64 if (row && row.rawAttributes && size(row.rawAttributes) > 0) {65 modifiedConfig = replacePlaceholders(modifiedConfig, row.rawAttributes);66 }67 const fmtInstance = formatterRegistry.getFormatter(type);68 if (!fmtInstance || !isFunction(fmtInstance.format)) {69 console.error('[FormattersService.format] invalid formatter with type: ' + type, fmtInstance);70 return FormatterService.errorMessage;71 }72 const formatProps = {73 ...props,74 config: modifiedConfig,75 format: FormatterService.format76 };77 const formatSingleValue = (data, valueIndex = 0) =>78 FormatterService._formatSingleValueCellImpl(data, { ...formatProps, valueIndex }, fmtInstance);79 if (Array.isArray(cell)) {80 if (cell.length === 1) {81 return formatSingleValue(cell[0]);82 }83 return cell.map((elem, i) => <div key={i}>{formatSingleValue(elem, i)}</div>);84 }85 return formatSingleValue(cell);86 }87 static _formatSingleValueCellImpl(cell, formatProps, fmtInstance) {88 if (cell == null) {89 return '';90 }91 let cellValue = cell;92 if (fmtInstance.getSupportedCellType() === CellType.VALUE_WITH_DISP) {93 if (!isPlainObject(cellValue)) {94 cellValue = { value: cellValue, disp: cellValue };95 } else {96 cellValue = {97 value: valueOrNull(cellValue.value),98 disp: valueOrNull(cellValue.disp || cellValue.value)99 };100 }101 } else if (fmtInstance.getSupportedCellType() === CellType.SCALAR) {102 if (isPlainObject(cellValue) && cellValue.value) {103 cellValue = cellValue.value;104 }105 }106 formatProps.cell = cellValue;107 try {108 return <FormatterService.PopperWrapper contentComponent={fmtInstance.format(formatProps)} />;109 } catch (e) {110 console.error('[FormattersService._formatSingleValueCellImpl] error. Props: ', formatProps, e);111 return FormatterService.errorMessage;112 }113 }114}...
documentList.js
Source:documentList.js
1export const documentList = {2 uiFramework: "custom-containers-local",3 moduleName: "egov-tradelicence",4 componentPath: "DocumentListContainer",5 props: {6 buttonLabel: {7 labelName: "UPLOAD FILE",8 labelKey: "TL_BUTTON_UPLOAD FILE"9 },10 inputProps : [11 {12 type : "OWNERIDPROOF",13 description: {14 labelName: "Only .jpg and .pdf files. 6MB max file size.",15 labelKey: "TL_UPLOAD_RESTRICTIONS"16 },17 formatProps :{18 accept : "image/*, .pdf, .png, .jpeg",19 }, 20 maxFileSize: 600021 },22 {23 type : "OWNERSHIPPROOF",24 description: {25 labelName: "Only .jpg and .pdf files. 6MB max file size.",26 labelKey: "TL_UPLOAD_RESTRICTIONS"27 },28 formatProps :{29 accept : "image/*, .pdf, .png, .jpeg",30 }, 31 maxFileSize: 600032 },33 {34 type : "OWNERPHOTO",35 description: {36 labelName: "Only .png and .jpeg 6MB max file size.",37 labelKey: "TL_UPLOAD_IMAGE_RESTRICTIONS"38 },39 formatProps :{40 accept: "image/*, .png, .jpeg",41 }, 42 maxFileSize: 300043 },44 {45 type : "OLDLICENCENO",46 description: {47 labelName: "Only .jpg and .pdf files. 6MB max file size.",48 labelKey: "TL_UPLOAD_RESTRICTIONS"49 },50 formatProps :{51 accept : "image/*, .pdf, .png, .jpeg",52 }, 53 maxFileSize: 600054 }55 ],56 documentTypePrefix: "TL_",57 }...
index.js
Source:index.js
1import React, { memo } from 'react';2import NumberFormat from 'react-number-format';3import PropTypes from 'prop-types';4import Text from '../Text';5const Number = ({6 value,7 bold,8 style,9 currency,10 textProps,11 formatProps,12 children,13 withRender,14 ...props15}) => {16 const formatValue = value || children;17 if (formatValue === null || typeof formatValue === 'undefined') {18 return null;19 }20 const renderText = textValue => (21 <Text bold={bold} style={style} {...textProps} {...props}>22 {textValue}23 </Text>24 );25 return (26 <NumberFormat27 value={formatValue}28 prefix={currency ? 'Rp ' : ''}29 displayType="text"30 decimalSeparator=","31 thousandSeparator="."32 withRender33 renderText={renderText}34 {...formatProps}35 />36 );37};38Number.propTypes = {39 bold: PropTypes.bool,40 value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),41 style: PropTypes.any,42 currency: PropTypes.bool,43 textProps: PropTypes.object,44 formatProps: PropTypes.object,45 withRender: PropTypes.bool,46 children: PropTypes.oneOfType([PropTypes.number, PropTypes.string])47};48Number.defaultProps = {49 style: {},50 bold: false,51 value: null,52 currency: false,53 textProps: null,54 withRender: true,55 formatProps: null,56 children: null57};...
utils.js
Source:utils.js
1const isUndefined = val => typeof val === "undefined";2const isFunction = val =>3 Object.prototype.toString.apply(val) === "[object Function]";4const camelCase = str => {5 return str6 .replace(/-a([a-z])/g, ($0, $1) => $1.toUpperCase())7 .replace("-", "");8};9const formatCss = props => {10 const prefixes = ["-webkit-", "-moz-", "-ms-"];11 const result = [];12 const regPrefix = /transform|transition/;13 for (const key in props) {14 if (props.hasOwnProperty(key)) {15 const styleValue = props[key];16 if (regPrefix.test(key)) {17 for (let i = 0; i < prefixes.length; i++) {18 const stylename = camelCase(prefixes[i] + key);19 result[stylename] = styleValue.replace(regPrefix, `${prefixes[i]}$&`);20 }21 }22 result[key] = styleValue;23 }24 }25 return result;26};27const addPrefixCss = (element, props) => {28 const formatProps = formatCss(props);29 for (const key in formatProps) {30 if (formatProps.hasOwnProperty(key)) {31 element.style[key] = formatProps[key];32 }33 }34};...
statements.js
Source:statements.js
1var groupBy = require('lodash/collection').groupBy;2var statement = {}3const baseInsertStatement =4 'UNWIND $props AS prop MERGE (n:Base {objectid: prop.source}) ON MATCH SET n:{0} ON CREATE SET n:{0} MERGE (m:Base {objectid: prop.target}) ON MATCH SET m:{1} ON CREATE SET m:{1} MERGE (n)-[r:{2} {3}]->(m)';5statement.insertNewAWS = function(queries, formatProps, queryProps) {6 if (formatProps.length < 4) {7 throw new NotEnoughArgumentsException();8 }9 if (queryProps.length == 0) {10 return;11 }12 let hash = `${formatProps[0]}-${formatProps[1]}-${formatProps[2]}-${Object.keys(queries).length}`;13 if (queries[hash]) {14 queries[hash].props = queries[hash].props.concat(queryProps);15 } else {16 queries[hash] = {};17 if (formatProps.length < 4) {18 throw new NotEnoughArgumentsException();19 }20 queries[hash].statement = baseInsertStatement.formatn(...formatProps);21 queries[hash].props = [].concat(queryProps);22 }23}...
Using AI Code Generation
1const { formatProps } = require('playwright/lib/utils/stackTrace');2const { test } = require('@playwright/test');3test('test', async ({ page }) => {4 await page.click('text=Get started');5 await page.click('text=Docs');6 await page.click('text=API');
Using AI Code Generation
1const { formatProps } = require('playwright/lib/server/serializers/serializers');2const { serializeError } = require('playwright/lib/server/serializers/errorSerializer');3const { serializeResponse } = require('playwright/lib/server/serializers/responseSerializer');4const { serializeHeaders } = require('playwright/lib/server/serializers/headersSerializer');5const { serializeRequest } = require('playwright/lib/server/serializers/requestSerializer');6const { serializeCookie } = require('playwright/lib/server/serializers/cookieSerializer');7const { serializeFrame } = require('playwright/lib/server/serializers/frameSerializer');8const { serializeElementHandle } = require('playwright/lib/server/serializers/elementHandleSerializer');9const { serializeJSHandle } = require('playwright/lib/server/serializers/jsHandleSerializer');10const { serializeExecutionContext } = require('playwright/lib/server/serializers/executionContextSerializer');11const { serializeWorker } = require('playwright/lib/server/serializers/workerSerializer');12const { serializeConsoleMessage } = require('playwright/lib/server/serializers/consoleMessageSerializer');13const { serializeDialog } = require('playwright/lib/server/serializers/dialogSerializer');14const { serializeDownload } = require('playwright/lib/server/serializers/downloadSerializer');15const { serializePage } = require('playwright/lib/server/serializers/pageSerializer');16const { serializeBrowserContext } = require('playwright/lib/server/serializers/browserContextSerializer');17const { serializeBrowser } = require('playwright/lib/server/serializers/browserSerializer');18const { serializeBrowserType } = require('playwright/lib/server/serializers/browserTypeSerializer');19const { serializeSelectors } = require('playwright/lib/server/serializers/selectorsSerializer');20const { serializeErrorLog } = require('playwright/lib/server/serializers/errorLogSerializer');21const { serializeCoverage } = require('playwright/lib/server/serializers/coverageSerializer');22const { serializeVideo } = require('playwright/lib/server/serializers/videoSerializer');23const serializers = {
Using AI Code Generation
1const { formatProps } = require('playwright/lib/server/inspector/inspector');2const { test } = require('@playwright/test');3test('basic test', async ({ page }) => {4 const a = await page.$('a');5 const props = await a.asElement().getPropertyList();6 console.log(formatProps(props));7});8const { test } = require('@playwright/test');9test('basic test', async ({ page }) => {10 const a = await page.$('a');11 const props = await a.asElement().getPropertyList();12 const propsArray = [];13 for (let prop of props) {14 propsArray.push([prop.name, prop.value]);15 }16 console.log(propsArray);17});18const { test } = require('@playwright/test');19test('basic test', async ({ page }) => {20 const a = await page.$('a');21 const props = await a.asElement().getPropertyList();22 const propsArray = props.map((prop) => [prop.name, prop.value]);23 console.log(propsArray);24});25const { test } = require('@playwright/test');26test('basic test', async ({ page }) => {27 const a = await page.$('a');28 const props = await a.asElement().getPropertyList();29 const propsArray = props.map(({ name, value }) => [name, value]);30 console.log(propsArray);31});32const { test } = require('@playwright/test');33test('basic test', async ({ page }) => {
Using AI Code Generation
1const { formatProps } = require('@playwright/test/lib/server/inspector/inspector');2const obj = {3 baz: {4 },5};6console.log(formatProps(obj));7[Apache 2.0](./LICENSE)
Using AI Code Generation
1const { formatProps } = require('playwright/lib/internal/stackTrace');2const obj = {3};4console.log(formatProps(obj));5const { formatException } = require('playwright/lib/internal/stackTrace');6const error = new Error('foo');7console.log(formatException(error));8const { formatConsoleMessage } = require('playwright/lib/internal/stackTrace');9const message = {10 location: {11 }12};13console.log(formatConsoleMessage(message));14const { formatCallFrames } = require('playwright/lib/internal/stackTrace');15 {
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!