@bem-react/classname 1.5.11 → 1.5.13-dev.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.5.12](https://github.com/bem/bem-react/compare/@bem-react/classname@1.5.11...@bem-react/classname@1.5.12) (2021-09-03)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **classname:** add correct overloads for cn formatter ([47758e7](https://github.com/bem/bem-react/commit/47758e76847e34babddbb99b60fd3f9827f49e95))
11
+
6
12
  ## [1.5.11](https://github.com/bem/bem-react/compare/@bem-react/classname@1.5.10...@bem-react/classname@1.5.11) (2021-06-08)
7
13
 
8
14
  ### Bug Fixes
@@ -38,6 +38,7 @@ function withNaming(preset) {
38
38
  }
39
39
  }
40
40
  if (mix !== undefined) {
41
+ mix = Array.isArray(mix) ? mix : [mix];
41
42
  for (var i = 0, len = mix.length; i < len; i++) {
42
43
  var value = mix[i];
43
44
  // Skipping non-string values and empty strings
@@ -57,7 +58,7 @@ function withNaming(preset) {
57
58
  return function cnGenerator(b, e) {
58
59
  return function (elemOrMods, elemModsOrBlockMix, elemMix) {
59
60
  if (typeof elemOrMods === 'string') {
60
- if (Array.isArray(elemModsOrBlockMix)) {
61
+ if (typeof elemModsOrBlockMix === 'string' || Array.isArray(elemModsOrBlockMix)) {
61
62
  return stringify(b, elemOrMods, undefined, elemModsOrBlockMix);
62
63
  }
63
64
  return stringify(b, elemOrMods, elemModsOrBlockMix, elemMix);
@@ -1 +1 @@
1
- 'use strict';function r(r){function e(e,i,a,o){var f=i?t+e+r.e+i:t+e,v=f;if(a){var u=' '+v+r.m;for(var s in a)if(a.hasOwnProperty(s)){var p=a[s];!0===p?v+=u+s:p&&(v+=u+s+n+p)}}if(void 0!==o)for(var c=0,l=o.length;c<l;c++){var y=o[c];if(y&&'string'==typeof y.valueOf())for(var g=y.valueOf().split(' '),d=0;d<g.length;d++){var h=g[d];h!==f&&(v+=' '+h)}}return v}var t=r.n||'',n=r.v||r.m;return function(r,t){return function(n,i,a){return'string'==typeof n?Array.isArray(i)?e(r,n,void 0,i):e(r,n,i,a):e(r,t,n,i)}}}Object.defineProperty(exports,'__esModule',{value:!0});var e=r({e:'-',m:'_'});exports.cn=e,exports.withNaming=r;
1
+ 'use strict';function r(r){function t(t,i,a,o){var f=i?e+t+r.e+i:e+t,v=f;if(a){var s=' '+v+r.m;for(var u in a)if(a.hasOwnProperty(u)){var p=a[u];!0===p?v+=s+u:p&&(v+=s+u+n+p)}}if(void 0!==o)for(var y=0,c=(o=Array.isArray(o)?o:[o]).length;y<c;y++){var l=o[y];if(l&&'string'==typeof l.valueOf())for(var g=l.valueOf().split(' '),d=0;d<g.length;d++){var h=g[d];h!==f&&(v+=' '+h)}}return v}var e=r.n||'',n=r.v||r.m;return function(r,e){return function(n,i,a){return'string'==typeof n?'string'==typeof i||Array.isArray(i)?t(r,n,void 0,i):t(r,n,i,a):t(r,e,n,i)}}}Object.defineProperty(exports,'__esModule',{value:!0});var t=r({e:'-',m:'_'});exports.cn=t,exports.withNaming=r;
package/classname.d.ts CHANGED
@@ -1,28 +1,30 @@
1
1
  /**
2
2
  * List of classname.
3
3
  */
4
- export declare type ClassNameList = Array<string | undefined>;
4
+ export type ClassNameList = string | Array<string | undefined>;
5
5
  /**
6
6
  * Allowed modifiers format.
7
7
  *
8
8
  * @see https://en.bem.info/methodology/key-concepts/#modifier
9
9
  */
10
- export declare type NoStrictEntityMods = Record<string, string | boolean | number | undefined>;
10
+ export type NoStrictEntityMods = Record<string, string | boolean | number | undefined>;
11
11
  /**
12
12
  * BEM Entity className initializer.
13
13
  */
14
- export declare type ClassNameInitilizer = (blockName: string, elemName?: string) => ClassNameFormatter;
14
+ export type ClassNameInitilizer = (blockName: string, elemName?: string) => ClassNameFormatter;
15
15
  /**
16
16
  * BEM Entity className formatter.
17
17
  */
18
- declare function classNameFormatter(): string;
19
- declare function classNameFormatter(elemNameOrBlockMods: null, elemMix: ClassNameList): string;
20
- declare function classNameFormatter(elemNameOrBlockMods: NoStrictEntityMods | string, elemModsOrBlockMix?: NoStrictEntityMods | ClassNameList | null, elemMix?: ClassNameList): string;
21
- export declare type ClassNameFormatter = typeof classNameFormatter;
18
+ export interface ClassNameFormatter {
19
+ (): string;
20
+ (mods?: NoStrictEntityMods | null, mix?: ClassNameList): string;
21
+ (elemName: string, elemMix?: ClassNameList): string;
22
+ (elemName: string, elemMods?: NoStrictEntityMods | null, elemMix?: ClassNameList): string;
23
+ }
22
24
  /**
23
25
  * Settings for the naming convention.
24
26
  */
25
- export declare type Preset = {
27
+ export type Preset = {
26
28
  /**
27
29
  * Global namespace.
28
30
  *
@@ -82,4 +84,3 @@ export declare function withNaming(preset: Preset): ClassNameInitilizer;
82
84
  * @see https://en.bem.info/methodology/naming-convention/#react-style
83
85
  */
84
86
  export declare const cn: ClassNameInitilizer;
85
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bem-react/classname",
3
- "version": "1.5.11",
3
+ "version": "1.5.13-dev.19+c1c9731",
4
4
  "description": "BEM React ClassName",
5
5
  "homepage": "https://github.com/bem/bem-react/tree/master/packages/classname",
6
6
  "repository": "https://github.com/bem/bem-react",
@@ -26,5 +26,5 @@
26
26
  "build": "node ../../scripts/rollup/build.js",
27
27
  "unit": "../../node_modules/.bin/jest --config ../../.config/jest/jest.config.js"
28
28
  },
29
- "gitHead": "1622b6315793c8d2dc62128f2df72185443e40a4"
29
+ "gitHead": "c1c97312b80d24da88eafffd8e7c235887d65bd6"
30
30
  }