{"version":3,"file":"public-class-names.mjs","names":[],"sources":["../../src/public-class-names.ts"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\n\n/**\n * Typography variants that have a matching `ndl-typography-<variant>` class\n * in the shipped stylesheet (`src/base/typography.css`). Mirrors the keys of\n * `tokens.typography`.\n */\nexport const NDL_TYPOGRAPHY_VARIANTS = [\n  'code',\n  'display',\n  'title-1',\n  'title-2',\n  'title-3',\n  'title-4',\n  'subheading-large',\n  'subheading-medium',\n  'subheading-small',\n  'body-large',\n  'body-medium',\n  'body-small',\n  'label',\n] as const;\n\nexport type NdlTypographyVariant = (typeof NDL_TYPOGRAPHY_VARIANTS)[number];\n\n/** Class name prefix used by the public typography classes. */\nexport const NDL_TYPOGRAPHY_CLASS_PREFIX = 'ndl-typography-';\n\n/** Theme scope classes, also exposed through `useNeedleTheme().themeClassName`. */\nexport const NDL_THEME_CLASS_NAMES = [\n  'ndl-theme-light',\n  'ndl-theme-dark',\n] as const;\n\n/**\n * The complete list of `ndl-*` class names that are part of the public API:\n * every `ndl-typography-<variant>` class and the theme scope classes.\n *\n * Exact names rather than prefixes, because internal component classes share\n * those prefixes (e.g. `ndl-theme-wrapper` from `NeedleThemeProvider`).\n *\n * Every other `ndl-*` class in the shipped stylesheet is an implementation\n * detail of a component and may change without notice. Consumers who want to\n * prevent accidental reliance on those internals can ban `ndl-*` class names in\n * their own code and allow only these names. For example, with ESLint's\n * `no-restricted-syntax`:\n *\n * ```js\n * const { NDL_INTERNAL_CLASS_PATTERN } = require('@neo4j-ndl/base');\n * const regex = `/${NDL_INTERNAL_CLASS_PATTERN.source}/`;\n *\n * module.exports = {\n *   rules: {\n *     'no-restricted-syntax': [\n *       'error',\n *       {\n *         selector: `Literal[value=${regex}], TemplateElement[value.raw=${regex}]`,\n *         message:\n *           'Do not style against internal ndl-* component classes. Use component props or your own class names.',\n *       },\n *     ],\n *   },\n * };\n * ```\n *\n * And with Stylelint's `selector-disallowed-list`:\n *\n * ```js\n * const { NDL_INTERNAL_CLASS_PATTERN } = require('@neo4j-ndl/base');\n *\n * module.exports = {\n *   rules: {\n *     'selector-disallowed-list': [\n *       [new RegExp(`\\\\.${NDL_INTERNAL_CLASS_PATTERN.source}`)],\n *       { message: 'Do not style against internal ndl-* component classes.' },\n *     ],\n *   },\n * };\n * ```\n */\nexport const NDL_PUBLIC_CLASS_NAMES: readonly string[] = [\n  ...NDL_TYPOGRAPHY_VARIANTS.map(\n    (variant) => `${NDL_TYPOGRAPHY_CLASS_PREFIX}${variant}`,\n  ),\n  ...NDL_THEME_CLASS_NAMES,\n];\n\nconst publicClassNameAlternation = NDL_PUBLIC_CLASS_NAMES.join('|');\n\n/**\n * Matches exactly one of {@link NDL_PUBLIC_CLASS_NAMES}.\n */\nexport const NDL_PUBLIC_CLASS_PATTERN = new RegExp(\n  `^(?:${publicClassNameAlternation})$`,\n);\n\n/**\n * Matches an `ndl-*` class name that is **not** part of the public API, i.e.\n * an internal component class. Intended for lint rules that scan class\n * strings; the pattern is unanchored so it can match anywhere in a string\n * such as `\"my-class ndl-button\"`.\n */\nexport const NDL_INTERNAL_CLASS_PATTERN = new RegExp(\n  `(?<![\\\\w-])(?!(?:${publicClassNameAlternation})(?![\\\\w-]))ndl-[\\\\w-]+`,\n);\n\n/**\n * Returns `true` when the given class name is part of the public `ndl-*` API.\n *\n * @param className - A single class name (not a space separated list).\n */\nexport function isNdlPublicClassName(className: string): boolean {\n  return NDL_PUBLIC_CLASS_PATTERN.test(className);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,0BAA0B;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAKA,MAAa,8BAA8B;;AAG3C,MAAa,wBAAwB,CACnC,mBACA,gBACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,yBAA4C,CACvD,GAAG,wBAAwB,KACxB,YAAY,GAAG,8BAA8B,SAChD,GACA,GAAG,qBACL;AAEA,MAAM,6BAA6B,uBAAuB,KAAK,GAAG;;;;AAKlE,MAAa,2BAA2B,IAAI,OAC1C,OAAO,2BAA2B,GACpC;;;;;;;AAQA,MAAa,6BAA6B,IAAI,OAC5C,oBAAoB,2BAA2B,wBACjD;;;;;;AAOA,SAAgB,qBAAqB,WAA4B;CAC/D,OAAO,yBAAyB,KAAK,SAAS;AAChD"}