MCPcopy
hub / github.com/kuma-ui/kuma-ui / normalizeSelectorList

Method normalizeSelectorList

packages/sheet/src/sheet.ts:372–409  ·  view source on GitHub ↗
(
    props: Element["props"],
    className: string,
    globalOperators: Set<string>,
  )

Source from the content-addressed store, hash-verified

370 }
371
372 private normalizeSelectorList(
373 props: Element["props"],
374 className: string,
375 globalOperators: Set<string>,
376 ): { selectors: string[]; touched: boolean } {
377 const selectors: string[] = [];
378 const scopedPrefix = new RegExp(`^\\.${Sheet.escapeRegExp(className)}\\s*`);
379 let touched = false;
380
381 for (const entry of Sheet.toArray(props)) {
382 for (const selector of entry.split(",").map((s) => s.trim())) {
383 if (!selector) {
384 continue;
385 }
386
387 if (!selector.includes(":global")) {
388 selectors.push(selector);
389 continue;
390 }
391
392 touched = true;
393
394 const inners: string[] = [];
395 const body = unwrapGlobalOperator(selector, inners);
396 const cleaned = normalizeWhitespace(
397 inners.some((inner) => globalOperators.has(inner))
398 ? body
399 : body.replace(scopedPrefix, ""),
400 );
401
402 if (cleaned) {
403 selectors.push(cleaned);
404 }
405 }
406 }
407
408 return { selectors, touched };
409 }
410
411 getCSS(): string {
412 this.removeDuplicates();

Callers 1

Calls 4

unwrapGlobalOperatorFunction · 0.85
normalizeWhitespaceFunction · 0.85
escapeRegExpMethod · 0.80
toArrayMethod · 0.80

Tested by

no test coverage detected