How to use SubGroup method in storybook-root

Best JavaScript code snippet using storybook-root

subgroups.nocompat.invalid.vk.msl22.frag

Source:subgroups.nocompat.invalid.vk.msl22.frag Github

copy

Full Screen

1#pragma clang diagnostic ignored "-Wmissing-prototypes"2#include <metal_stdlib>3#include <simd/simd.h>4using namespace metal;5template<typename T>6inline T spvSubgroupBroadcast(T value, ushort lane)7{8 return simd_broadcast(value, lane);9}10template<>11inline bool spvSubgroupBroadcast(bool value, ushort lane)12{13 return !!simd_broadcast((ushort)value, lane);14}15template<uint N>16inline vec<bool, N> spvSubgroupBroadcast(vec<bool, N> value, ushort lane)17{18 return (vec<bool, N>)simd_broadcast((vec<ushort, N>)value, lane);19}20template<typename T>21inline T spvSubgroupBroadcastFirst(T value)22{23 return simd_broadcast_first(value);24}25template<>26inline bool spvSubgroupBroadcastFirst(bool value)27{28 return !!simd_broadcast_first((ushort)value);29}30template<uint N>31inline vec<bool, N> spvSubgroupBroadcastFirst(vec<bool, N> value)32{33 return (vec<bool, N>)simd_broadcast_first((vec<ushort, N>)value);34}35inline uint4 spvSubgroupBallot(bool value)36{37 simd_vote vote = simd_ballot(value);38 // simd_ballot() returns a 64-bit integer-like object, but39 // SPIR-V callers expect a uint4. We must convert.40 // FIXME: This won't include higher bits if Apple ever supports41 // 128 lanes in an SIMD-group.42 return uint4(as_type<uint2>((simd_vote::vote_t)vote), 0, 0);43}44inline bool spvSubgroupBallotBitExtract(uint4 ballot, uint bit)45{46 return !!extract_bits(ballot[bit / 32], bit % 32, 1);47}48inline uint spvSubgroupBallotFindLSB(uint4 ballot, uint gl_SubgroupSize)49{50 uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0));51 ballot &= mask;52 return select(ctz(ballot.x), select(32 + ctz(ballot.y), select(64 + ctz(ballot.z), select(96 + ctz(ballot.w), uint(-1), ballot.w == 0), ballot.z == 0), ballot.y == 0), ballot.x == 0);53}54inline uint spvSubgroupBallotFindMSB(uint4 ballot, uint gl_SubgroupSize)55{56 uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0));57 ballot &= mask;58 return select(128 - (clz(ballot.w) + 1), select(96 - (clz(ballot.z) + 1), select(64 - (clz(ballot.y) + 1), select(32 - (clz(ballot.x) + 1), uint(-1), ballot.x == 0), ballot.y == 0), ballot.z == 0), ballot.w == 0);59}60inline uint spvPopCount4(uint4 ballot)61{62 return popcount(ballot.x) + popcount(ballot.y) + popcount(ballot.z) + popcount(ballot.w);63}64inline uint spvSubgroupBallotBitCount(uint4 ballot, uint gl_SubgroupSize)65{66 uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0));67 return spvPopCount4(ballot & mask);68}69inline uint spvSubgroupBallotInclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID)70{71 uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0));72 return spvPopCount4(ballot & mask);73}74inline uint spvSubgroupBallotExclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID)75{76 uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0));77 return spvPopCount4(ballot & mask);78}79template<typename T>80inline bool spvSubgroupAllEqual(T value)81{82 return simd_all(all(value == simd_broadcast_first(value)));83}84template<>85inline bool spvSubgroupAllEqual(bool value)86{87 return simd_all(value) || !simd_any(value);88}89template<uint N>90inline bool spvSubgroupAllEqual(vec<bool, N> value)91{92 return simd_all(all(value == (vec<bool, N>)simd_broadcast_first((vec<ushort, N>)value)));93}94template<typename T>95inline T spvSubgroupShuffle(T value, ushort lane)96{97 return simd_shuffle(value, lane);98}99template<>100inline bool spvSubgroupShuffle(bool value, ushort lane)101{102 return !!simd_shuffle((ushort)value, lane);103}104template<uint N>105inline vec<bool, N> spvSubgroupShuffle(vec<bool, N> value, ushort lane)106{107 return (vec<bool, N>)simd_shuffle((vec<ushort, N>)value, lane);108}109template<typename T>110inline T spvSubgroupShuffleXor(T value, ushort mask)111{112 return simd_shuffle_xor(value, mask);113}114template<>115inline bool spvSubgroupShuffleXor(bool value, ushort mask)116{117 return !!simd_shuffle_xor((ushort)value, mask);118}119template<uint N>120inline vec<bool, N> spvSubgroupShuffleXor(vec<bool, N> value, ushort mask)121{122 return (vec<bool, N>)simd_shuffle_xor((vec<ushort, N>)value, mask);123}124template<typename T>125inline T spvSubgroupShuffleUp(T value, ushort delta)126{127 return simd_shuffle_up(value, delta);128}129template<>130inline bool spvSubgroupShuffleUp(bool value, ushort delta)131{132 return !!simd_shuffle_up((ushort)value, delta);133}134template<uint N>135inline vec<bool, N> spvSubgroupShuffleUp(vec<bool, N> value, ushort delta)136{137 return (vec<bool, N>)simd_shuffle_up((vec<ushort, N>)value, delta);138}139template<typename T>140inline T spvSubgroupShuffleDown(T value, ushort delta)141{142 return simd_shuffle_down(value, delta);143}144template<>145inline bool spvSubgroupShuffleDown(bool value, ushort delta)146{147 return !!simd_shuffle_down((ushort)value, delta);148}149template<uint N>150inline vec<bool, N> spvSubgroupShuffleDown(vec<bool, N> value, ushort delta)151{152 return (vec<bool, N>)simd_shuffle_down((vec<ushort, N>)value, delta);153}154template<typename T>155inline T spvQuadBroadcast(T value, uint lane)156{157 return quad_broadcast(value, lane);158}159template<>160inline bool spvQuadBroadcast(bool value, uint lane)161{162 return !!quad_broadcast((ushort)value, lane);163}164template<uint N>165inline vec<bool, N> spvQuadBroadcast(vec<bool, N> value, uint lane)166{167 return (vec<bool, N>)quad_broadcast((vec<ushort, N>)value, lane);168}169template<typename T>170inline T spvQuadSwap(T value, uint dir)171{172 return quad_shuffle_xor(value, dir + 1);173}174template<>175inline bool spvQuadSwap(bool value, uint dir)176{177 return !!quad_shuffle_xor((ushort)value, dir + 1);178}179template<uint N>180inline vec<bool, N> spvQuadSwap(vec<bool, N> value, uint dir)181{182 return (vec<bool, N>)quad_shuffle_xor((vec<ushort, N>)value, dir + 1);183}184struct main0_out185{186 float FragColor [[color(0)]];187};188fragment main0_out main0(uint gl_SubgroupSize [[threads_per_simdgroup]], uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]])189{190 main0_out out = {};191 uint4 gl_SubgroupEqMask = gl_SubgroupInvocationID >= 32 ? uint4(0, (1 << (gl_SubgroupInvocationID - 32)), uint2(0)) : uint4(1 << gl_SubgroupInvocationID, uint3(0));192 uint4 gl_SubgroupGeMask = uint4(insert_bits(0u, 0xFFFFFFFF, min(gl_SubgroupInvocationID, 32u), (uint)max(min((int)gl_SubgroupSize, 32) - (int)gl_SubgroupInvocationID, 0)), insert_bits(0u, 0xFFFFFFFF, (uint)max((int)gl_SubgroupInvocationID - 32, 0), (uint)max((int)gl_SubgroupSize - (int)max(gl_SubgroupInvocationID, 32u), 0)), uint2(0));193 uint4 gl_SubgroupGtMask = uint4(insert_bits(0u, 0xFFFFFFFF, min(gl_SubgroupInvocationID + 1, 32u), (uint)max(min((int)gl_SubgroupSize, 32) - (int)gl_SubgroupInvocationID - 1, 0)), insert_bits(0u, 0xFFFFFFFF, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0), (uint)max((int)gl_SubgroupSize - (int)max(gl_SubgroupInvocationID + 1, 32u), 0)), uint2(0));194 uint4 gl_SubgroupLeMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0));195 uint4 gl_SubgroupLtMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0));196 out.FragColor = float(gl_SubgroupSize);197 out.FragColor = float(gl_SubgroupInvocationID);198 bool _24 = simd_is_first();199 bool elected = _24;200 out.FragColor = float4(gl_SubgroupEqMask).x;201 out.FragColor = float4(gl_SubgroupGeMask).x;202 out.FragColor = float4(gl_SubgroupGtMask).x;203 out.FragColor = float4(gl_SubgroupLeMask).x;204 out.FragColor = float4(gl_SubgroupLtMask).x;205 float4 broadcasted = spvSubgroupBroadcast(float4(10.0), 8u);206 bool2 broadcasted_bool = spvSubgroupBroadcast(bool2(true), 8u);207 float3 first = spvSubgroupBroadcastFirst(float3(20.0));208 bool4 first_bool = spvSubgroupBroadcastFirst(bool4(false));209 uint4 ballot_value = spvSubgroupBallot(true);210 bool inverse_ballot_value = spvSubgroupBallotBitExtract(ballot_value, gl_SubgroupInvocationID);211 bool bit_extracted = spvSubgroupBallotBitExtract(uint4(10u), 8u);212 uint bit_count = spvSubgroupBallotBitCount(ballot_value, gl_SubgroupSize);213 uint inclusive_bit_count = spvSubgroupBallotInclusiveBitCount(ballot_value, gl_SubgroupInvocationID);214 uint exclusive_bit_count = spvSubgroupBallotExclusiveBitCount(ballot_value, gl_SubgroupInvocationID);215 uint lsb = spvSubgroupBallotFindLSB(ballot_value, gl_SubgroupSize);216 uint msb = spvSubgroupBallotFindMSB(ballot_value, gl_SubgroupSize);217 uint shuffled = spvSubgroupShuffle(10u, 8u);218 bool shuffled_bool = spvSubgroupShuffle(true, 9u);219 uint shuffled_xor = spvSubgroupShuffleXor(30u, 8u);220 bool shuffled_xor_bool = spvSubgroupShuffleXor(false, 9u);221 uint shuffled_up = spvSubgroupShuffleUp(20u, 4u);222 bool shuffled_up_bool = spvSubgroupShuffleUp(true, 4u);223 uint shuffled_down = spvSubgroupShuffleDown(20u, 4u);224 bool shuffled_down_bool = spvSubgroupShuffleDown(false, 4u);225 bool has_all = simd_all(true);226 bool has_any = simd_any(true);227 bool has_equal = spvSubgroupAllEqual(0);228 has_equal = spvSubgroupAllEqual(true);229 has_equal = spvSubgroupAllEqual(float3(0.0, 1.0, 2.0));230 has_equal = spvSubgroupAllEqual(bool4(true, true, false, true));231 float4 added = simd_sum(float4(20.0));232 int4 iadded = simd_sum(int4(20));233 float4 multiplied = simd_product(float4(20.0));234 int4 imultiplied = simd_product(int4(20));235 float4 lo = simd_min(float4(20.0));236 float4 hi = simd_max(float4(20.0));237 int4 slo = simd_min(int4(20));238 int4 shi = simd_max(int4(20));239 uint4 ulo = simd_min(uint4(20u));240 uint4 uhi = simd_max(uint4(20u));241 uint4 anded = simd_and(ballot_value);242 uint4 ored = simd_or(ballot_value);243 uint4 xored = simd_xor(ballot_value);244 added = simd_prefix_inclusive_sum(added);245 iadded = simd_prefix_inclusive_sum(iadded);246 multiplied = simd_prefix_inclusive_product(multiplied);247 imultiplied = simd_prefix_inclusive_product(imultiplied);248 added = simd_prefix_exclusive_sum(multiplied);249 multiplied = simd_prefix_exclusive_product(multiplied);250 iadded = simd_prefix_exclusive_sum(imultiplied);251 imultiplied = simd_prefix_exclusive_product(imultiplied);252 added = quad_sum(added);253 multiplied = quad_product(multiplied);254 iadded = quad_sum(iadded);255 imultiplied = quad_product(imultiplied);256 lo = quad_min(lo);257 hi = quad_max(hi);258 ulo = quad_min(ulo);259 uhi = quad_max(uhi);260 slo = quad_min(slo);261 shi = quad_max(shi);262 anded = quad_and(anded);263 ored = quad_or(ored);264 xored = quad_xor(xored);265 float4 swap_horiz = spvQuadSwap(float4(20.0), 0u);266 bool4 swap_horiz_bool = spvQuadSwap(bool4(true), 0u);267 float4 swap_vertical = spvQuadSwap(float4(20.0), 1u);268 bool4 swap_vertical_bool = spvQuadSwap(bool4(true), 1u);269 float4 swap_diagonal = spvQuadSwap(float4(20.0), 2u);270 bool4 swap_diagonal_bool = spvQuadSwap(bool4(true), 2u);271 float4 quad_broadcast0 = spvQuadBroadcast(float4(20.0), 3u);272 bool4 quad_broadcast_bool = spvQuadBroadcast(bool4(true), 3u);273 return out;...

Full Screen

Full Screen

Stack.js

Source:Stack.js Github

copy

Full Screen

1// Utility functions for ordering and stacking of items2var EPSILON = 0.001; // used when checking collisions, to prevent round-off errors3/**4 * Order items by their start data5 * @param {Item[]} items6 */7exports.orderByStart = function(items) {8 items.sort(function (a, b) {9 return a.data.start - b.data.start;10 });11};12/**13 * Order items by their end date. If they have no end date, their start date14 * is used.15 * @param {Item[]} items16 */17exports.orderByEnd = function(items) {18 items.sort(function (a, b) {19 var aTime = ('end' in a.data) ? a.data.end : a.data.start,20 bTime = ('end' in b.data) ? b.data.end : b.data.start;21 return aTime - bTime;22 });23};24/**25 * Adjust vertical positions of the items such that they don't overlap each26 * other.27 * @param {Item[]} items28 * All visible items29 * @param {{item: {horizontal: number, vertical: number}, axis: number}} margin30 * Margins between items and between items and the axis.31 * @param {boolean} [force=false]32 * If true, all items will be repositioned. If false (default), only33 * items having a top===null will be re-stacked34 */35exports.stack = function(items, margin, force) {36 if (force) {37 // reset top position of all items38 for (var i = 0; i < items.length; i++) {39 items[i].top = null;40 }41 }42 // calculate new, non-overlapping positions43 for (var i = 0; i < items.length; i++) { // eslint-disable-line no-redeclare44 var item = items[i];45 if (item.stack && item.top === null) {46 // initialize top position47 item.top = margin.axis;48 do {49 // TODO: optimize checking for overlap. when there is a gap without items,50 // you only need to check for items from the next item on, not from zero51 var collidingItem = null;52 for (var j = 0, jj = items.length; j < jj; j++) {53 var other = items[j];54 if (other.top !== null && other !== item && other.stack && exports.collision(item, other, margin.item, other.options.rtl)) {55 collidingItem = other;56 break;57 }58 }59 if (collidingItem != null) {60 // There is a collision. Reposition the items above the colliding element61 item.top = collidingItem.top + collidingItem.height + margin.item.vertical;62 }63 } while (collidingItem);64 }65 }66};67/**68 * Adjust vertical positions of the items within a single subgroup such that they 69 * don't overlap each other.70 * @param {Item[]} items71 * All items withina subgroup72 * @param {{item: {horizontal: number, vertical: number}, axis: number}} margin73 * Margins between items and between items and the axis.74 * @param {subgroup} subgroup75 * The subgroup that is being stacked 76 */77exports.substack = function (items, margin, subgroup) {78 for (var i = 0; i < items.length; i++) {79 items[i].top = null;80 }81 // Set the initial height82 var subgroupHeight = subgroup.height;83 // calculate new, non-overlapping positions84 for (i = 0; i < items.length; i++) {85 var item = items[i];86 if (item.stack && item.top === null) {87 // initialize top position88 item.top = item.baseTop;//margin.axis + item.baseTop;89 do {90 // TODO: optimize checking for overlap. when there is a gap without items,91 // you only need to check for items from the next item on, not from zero92 var collidingItem = null;93 for (var j = 0, jj = items.length; j < jj; j++) {94 var other = items[j];95 if (other.top !== null && other !== item /*&& other.stack*/ && exports.collision(item, other, margin.item, other.options.rtl)) {96 collidingItem = other;97 break;98 }99 }100 if (collidingItem != null) {101 // There is a collision. Reposition the items above the colliding element102 item.top = collidingItem.top + collidingItem.height + margin.item.vertical;// + item.baseTop;103 }104 if (item.top + item.height > subgroupHeight) {105 subgroupHeight = item.top + item.height;106 }107 } while (collidingItem);108 }109 }110 // Set the new height111 subgroup.height = subgroupHeight - subgroup.top + 0.5 * margin.item.vertical;112};113/**114 * Adjust vertical positions of the items without stacking them115 * @param {Item[]} items116 * All visible items117 * @param {{item: {horizontal: number, vertical: number}, axis: number}} margin118 * Margins between items and between items and the axis.119 * @param {subgroups[]} subgroups120 * All subgroups121 * @param {boolean} stackSubgroups122 */123exports.nostack = function(items, margin, subgroups, stackSubgroups) {124 for (var i = 0; i < items.length; i++) {125 if (items[i].data.subgroup == undefined) {126 items[i].top = margin.item.vertical;127 } else if (items[i].data.subgroup !== undefined && stackSubgroups) {128 var newTop = 0;129 for (var subgroup in subgroups) {130 if (subgroups.hasOwnProperty(subgroup)) {131 if (subgroups[subgroup].visible == true && subgroups[subgroup].index < subgroups[items[i].data.subgroup].index) {132 newTop += subgroups[subgroup].height;133 subgroups[items[i].data.subgroup].top = newTop;134 }135 }136 }137 items[i].top = newTop + 0.5 * margin.item.vertical;138 }139 }140 if (!stackSubgroups) {141 exports.stackSubgroups(items, margin, subgroups)142 }143};144/**145 * Adjust vertical positions of the subgroups such that they don't overlap each146 * other.147 * @param {Array.<vis.Item>} items148 * @param {{item: {horizontal: number, vertical: number}, axis: number}} margin Margins between items and between items and the axis.149 * @param {subgroups[]} subgroups150 * All subgroups151 */152exports.stackSubgroups = function(items, margin, subgroups) {153 for (var subgroup in subgroups) {154 if (subgroups.hasOwnProperty(subgroup)) {155 subgroups[subgroup].top = 0;156 do {157 // TODO: optimize checking for overlap. when there is a gap without items,158 // you only need to check for items from the next item on, not from zero159 var collidingItem = null;160 for (var otherSubgroup in subgroups) {161 if (subgroups[otherSubgroup].top !== null && otherSubgroup !== subgroup && subgroups[subgroup].index > subgroups[otherSubgroup].index && exports.collisionByTimes(subgroups[subgroup], subgroups[otherSubgroup])) {162 collidingItem = subgroups[otherSubgroup];163 break;164 }165 }166 if (collidingItem != null) {167 // There is a collision. Reposition the subgroups above the colliding element168 subgroups[subgroup].top = collidingItem.top + collidingItem.height;169 }170 } while (collidingItem);171 }172 }173 for (var i = 0; i < items.length; i++) {174 if (items[i].data.subgroup !== undefined) {175 items[i].top = subgroups[items[i].data.subgroup].top + 0.5 * margin.item.vertical;176 }177 }178};179/**180 * Adjust vertical positions of the subgroups such that they don't overlap each181 * other, then stacks the contents of each subgroup individually.182 * @param {Item[]} subgroupItems183 * All the items in a subgroup184 * @param {{item: {horizontal: number, vertical: number}, axis: number}} margin185 * Margins between items and between items and the axis.186 * @param {subgroups[]} subgroups187 * All subgroups 188 */189exports.stackSubgroupsWithInnerStack = function (subgroupItems, margin, subgroups) {190 var doSubStack = false;191 192 // Run subgroups in their order (if any)193 var subgroupOrder = [];194 for(var subgroup in subgroups) {195 if (subgroups[subgroup].hasOwnProperty("index")) {196 subgroupOrder[subgroups[subgroup].index] = subgroup;197 }198 else {199 subgroupOrder.push(subgroup);200 }201 }202 for(var j = 0; j < subgroupOrder.length; j++) {203 subgroup = subgroupOrder[j];204 if (subgroups.hasOwnProperty(subgroup)) {205 doSubStack = doSubStack || subgroups[subgroup].stack;206 subgroups[subgroup].top = 0; 207 for (var otherSubgroup in subgroups) {208 if (subgroups[otherSubgroup].visible && subgroups[subgroup].index > subgroups[otherSubgroup].index) {209 subgroups[subgroup].top += subgroups[otherSubgroup].height;210 }211 }212 var items = subgroupItems[subgroup];213 for(var i = 0; i < items.length; i++) {214 if (items[i].data.subgroup !== undefined) {215 items[i].top = subgroups[items[i].data.subgroup].top + 0.5 * margin.item.vertical;216 if (subgroups[subgroup].stack) {217 items[i].baseTop = items[i].top; 218 }219 } 220 }221 if (doSubStack && subgroups[subgroup].stack) {222 exports.substack(subgroupItems[subgroup], margin, subgroups[subgroup]); 223 }224 }225 } 226};227/**228 * Test if the two provided items collide229 * The items must have parameters left, width, top, and height.230 * @param {Item} a The first item231 * @param {Item} b The second item232 * @param {{horizontal: number, vertical: number}} margin233 * An object containing a horizontal and vertical234 * minimum required margin.235 * @param {boolean} rtl236 * @return {boolean} true if a and b collide, else false237 */238exports.collision = function(a, b, margin, rtl) {239 if (rtl) {240 return ((a.right - margin.horizontal + EPSILON) < (b.right + b.width) &&241 (a.right + a.width + margin.horizontal - EPSILON) > b.right &&242 (a.top - margin.vertical + EPSILON) < (b.top + b.height) &&243 (a.top + a.height + margin.vertical - EPSILON) > b.top);244 } else {245 return ((a.left - margin.horizontal + EPSILON) < (b.left + b.width) &&246 (a.left + a.width + margin.horizontal - EPSILON) > b.left &&247 (a.top - margin.vertical + EPSILON) < (b.top + b.height) &&248 (a.top + a.height + margin.vertical - EPSILON) > b.top);249 }250};251/**252 * Test if the two provided objects collide253 * The objects must have parameters start, end, top, and height.254 * @param {Object} a The first Object255 * @param {Object} b The second Object256 * @return {boolean} true if a and b collide, else false257 */258exports.collisionByTimes = function(a, b) {259 return (260 (a.start <= b.start && a.end >= b.start && a.top < (b.top + b.height) && (a.top + a.height) > b.top ) ||261 (b.start <= a.start && b.end >= a.start && b.top < (a.top + a.height) && (b.top + b.height) > a.top )262 )...

Full Screen

Full Screen

subGroup.service.ts

Source:subGroup.service.ts Github

copy

Full Screen

1import { HttpException, HttpStatus, Injectable } from '@nestjs/common';2import { InjectRepository } from '@nestjs/typeorm';3import { Repository, DeepPartial } from 'typeorm';4import { CreateSubGroupDto } from './dto/create-sub-group.dto';5import { UpdateSubGroupDto } from './dto/update-sub-group.dto';6import { GroupEntity } from './entities/group.entity';7import { SubGroupEntity } from './entities/subGroup.entity';8@Injectable()9export class SubGroupService {10 constructor(11 @InjectRepository(SubGroupEntity)12 private readonly subgroupRepository: Repository<SubGroupEntity>,13 ) {}14 async create(subGroup: CreateSubGroupDto): Promise<SubGroupEntity> {15 const newSubGroup = this.subgroupRepository.create(subGroup);16 newSubGroup.group = {17 id: subGroup.groupId,18 } as GroupEntity;19 return await this.subgroupRepository.save(newSubGroup);20 }21 async findAll(): Promise<SubGroupEntity[]> {22 return await this.subgroupRepository.find();23 }24 async findOneById(subgroupId: number): Promise<SubGroupEntity> {25 return await this.subgroupRepository.findOne({ id: subgroupId });26 }27 async updateOne(28 subgroupId: number,29 updateSubGroup: DeepPartial<UpdateSubGroupDto>,30 ): Promise<SubGroupEntity> {31 const newSubGroup = this.subgroupRepository.create(updateSubGroup);32 if (updateSubGroup.groupId)33 newSubGroup.group = { id: updateSubGroup.groupId } as GroupEntity;34 await this.subgroupRepository.update({ id: subgroupId }, newSubGroup);35 const updatedSubGroup = await this.subgroupRepository.findOne(subgroupId);36 if (updatedSubGroup) {37 return updatedSubGroup;38 }39 throw new HttpException('Not found', HttpStatus.NOT_FOUND);40 }41 async deleteOne(subgroupId: number): Promise<SubGroupEntity[]> {42 const subgroupToRemove = await this.subgroupRepository.find({43 id: subgroupId,44 });45 return await this.subgroupRepository.remove(subgroupToRemove);46 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { SubGroup } from "storybook-root";2import { storiesOf } from "@storybook/react";3import { action } from "@storybook/addon-actions";4import { linkTo } from "@storybook/addon-links";5import Button from "./Button";6import Welcome from "./Welcome";7storiesOf("Welcome", module).add("to Storybook", () => <Welcome showApp={linkTo("Button")} />);8storiesOf("Button", module)9 .add("with text", () => <Button onClick={action("clicked")}>Hello Button</Button>)10 .add("with some emoji", () => (11 <Button onClick={action("clicked")}>12 ));13storiesOf("SubGroup", module)14 .add("with text", () => <Button onClick={action("clicked")}>Hello Button</Button>)15 .add("with some emoji", () => (16 <Button onClick={action("clicked")}>17 ));18storiesOf("SubGroup", module).add("with text", () => <Button onClick={action("clicked")}>Hello Button</Button>);19storiesOf("SubGroup", module).add("with some emoji", () => (20 <Button onClick={action("clicked")}>21));22storiesOf("SubGroup", module).add("with some emoji", () => (23 <Button onClick={action("clicked")}>24));25storiesOf("SubGroup", module)26 .add("with text", () => <Button onClick={action("clicked")}>Hello Button</Button>)27 .add("with some emoji", () => (28 <Button onClick={action("clicked")}>

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from "react";2import { SubGroup } from "storybook-root";3const Test = () => {4 return (5 );6};7export default Test;8import React from "react";9import { useSubGroup } from "./useSubGroup";10export const SubGroup = ({ name, children }) => {11 const { SubGroup } = useSubGroup();12 return (13 <SubGroup name={name}>{children}</SubGroup>14 );15};16import React, { useContext, useEffect, useState } from "react";17import { Context } from "./context";18export const useSubGroup = () => {19 const { state } = useContext(Context);20 const [SubGroup, setSubGroup] = useState(() => () => {});21 useEffect(() => {22 const SubGroup = ({ name, children }) => {23 const { subGroup } = state;24 const { subGroup1, subGroup2 } = subGroup;25 const { subGroup1: subGroup1Name, subGroup2: subGroup2Name } = subGroup;26 if (name === subGroup1Name) {27 return subGroup1;28 } else if (name === subGroup2Name) {29 return subGroup2;30 } else {31 return null;32 }33 };34 setSubGroup(() => SubGroup);35 }, [state]);36 return { SubGroup };37};38import React, { createContext, useState } from "react";39export const Context = createContext();40export const Provider = ({ children }) => {41 const [state, setState] = useState({42 subGroup: {43 }44 });

Full Screen

Using AI Code Generation

copy

Full Screen

1import { SubGroup } from 'storybook-root';2const SubGroup = new SubGroup('Group Name');3SubGroup.add('Story Name', () => <div>Hi</div>);4SubGroup.add('Story Name 2', () => <div>Hi</div>);5SubGroup.add('Story Name 3', () => <div>Hi</div>);6import { subGroup } from 'storybook-root';7const subGroup = subGroup('Group Name');8subGroup.add('Story Name', () => <div>Hi</div>);9subGroup.add('Story Name 2', () => <div>Hi</div>);10subGroup.add('Story Name 3', () => <div>Hi</div>);11import { subGroup } from 'storybook-root';12const subGroup = subGroup('Group Name');13subGroup.add('Story Name', () => <div>Hi</div>);14subGroup.add('Story Name 2', () => <div>Hi</div>);15subGroup.add('Story Name 3', () => <div>Hi</div>);16import { subGroup } from 'storybook-root';17const subGroup = subGroup('Group Name');18subGroup.add('Story Name', () => <div>Hi</div>);19subGroup.add('Story Name 2', () => <div>Hi</div>);20subGroup.add('Story Name 3', () => <div>Hi</div>);21import { subGroup } from 'storybook-root';22const subGroup = subGroup('Group Name');23subGroup.add('Story Name', () => <div>Hi</div>);24subGroup.add('Story Name 2', () => <div>Hi</div>);25subGroup.add('Story Name 3', () => <div>Hi</div>);26import { subGroup } from 'storybook-root';27const subGroup = subGroup('Group Name');28subGroup.add('Story Name', () => <div>Hi

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful