MCPcopy
hub / github.com/tailwindlabs/tailwindcss / createUtilities

Function createUtilities

packages/tailwindcss/src/utilities.ts:294–6067  ·  view source on GitHub ↗
(theme: Theme)

Source from the content-addressed store, hash-verified

292const LEGACY_NUMERIC_KEY = /(\d+)_(\d+)/g
293
294export function createUtilities(theme: Theme) {
295 let utilities = new Utilities()
296
297 /**
298 * Register list of suggestions for a class
299 */
300 function suggest(classRoot: string, defns: () => SuggestionDefinition[]) {
301 function* resolve(themeKeys: ThemeKey[]) {
302 for (let value of theme.keysInNamespaces(themeKeys)) {
303 yield value.replace(LEGACY_NUMERIC_KEY, (_, a, b) => {
304 return `${a}.${b}`
305 })
306 }
307 }
308
309 let suggestedFractions = [
310 '1/2',
311 '1/3',
312 '2/3',
313 '1/4',
314 '2/4',
315 '3/4',
316 '1/5',
317 '2/5',
318 '3/5',
319 '4/5',
320 '1/6',
321 '2/6',
322 '3/6',
323 '4/6',
324 '5/6',
325 '1/12',
326 '2/12',
327 '3/12',
328 '4/12',
329 '5/12',
330 '6/12',
331 '7/12',
332 '8/12',
333 '9/12',
334 '10/12',
335 '11/12',
336 ]
337
338 utilities.suggest(classRoot, () => {
339 let groups: SuggestionGroup[] = []
340
341 for (let defn of defns()) {
342 if (typeof defn === 'string') {
343 groups.push({ values: [defn], modifiers: [] })
344 continue
345 }
346
347 let values: (string | null)[] = [
348 ...(defn.values ?? []),
349 ...resolve(defn.valueThemeKeys ?? []),
350 ]
351

Callers 1

buildDesignSystemFunction · 0.90

Calls 15

staticMethod · 0.95
functionalMethod · 0.95
declFunction · 0.90
isPositiveIntegerFunction · 0.90
segmentFunction · 0.90
isValidSpacingMultiplierFunction · 0.90
compareBreakpointsFunction · 0.90
atRuleFunction · 0.90
isStrictPositiveIntegerFunction · 0.90
isLengthFunction · 0.90
atRootFunction · 0.90
styleRuleFunction · 0.90

Tested by

no test coverage detected