@unsass/selector 1.2.0 → 1.4.0

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
@@ -2,6 +2,42 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
4
4
 
5
+ ## 1.4.0 (2026-01-03)
6
+
7
+ * ci: add `release.config.js` ([6fb94ff](https://github.com/unsass/selector/commit/6fb94ff))
8
+ * ci: lint code ([e7c5ae5](https://github.com/unsass/selector/commit/e7c5ae5))
9
+ * ci: rename `node.js.yml` to `publish.yml` ([bdfb2a2](https://github.com/unsass/selector/commit/bdfb2a2))
10
+ * ci: update `commit-msg` ([7f78c1c](https://github.com/unsass/selector/commit/7f78c1c))
11
+ * feat: use the plain-CSS if() syntax ([bfda10e](https://github.com/unsass/selector/commit/bfda10e))
12
+ * chore: switch to ESM ([faee4d8](https://github.com/unsass/selector/commit/faee4d8))
13
+ * chore(deps-dev): bump to `@commitlint/cli` 20.3.0 ([581c39e](https://github.com/unsass/selector/commit/581c39e))
14
+ * chore(deps-dev): bump to `sass-true` 10.1.0 ([125f7b4](https://github.com/unsass/selector/commit/125f7b4))
15
+ * chore(deps-dev): bump to `stylelint` 16.26.1 ([9249a20](https://github.com/unsass/selector/commit/9249a20))
16
+ * chore(deps-dev): prevent dependencies vulnerabilities ([311b5f1](https://github.com/unsass/selector/commit/311b5f1))
17
+ * chore(deps): bump to `@commitlint/cli` 20.1.0 ([7873ab3](https://github.com/unsass/selector/commit/7873ab3))
18
+ * chore(deps): bump to `sass-true` 8.1.0 ([796746d](https://github.com/unsass/selector/commit/796746d))
19
+ * chore(deps): bump to `sass-true` 9.0.0 ([c6f302c](https://github.com/unsass/selector/commit/c6f302c))
20
+ * chore(deps): bump to `sass` 1.97.1 ([3dfbf70](https://github.com/unsass/selector/commit/3dfbf70))
21
+ * chore(deps): bump to `semantic-release` 25.0.1 ([93db310](https://github.com/unsass/selector/commit/93db310))
22
+ * chore(deps): bump to `stylelint-config-unsass` 2.0.0 ([ccb922e](https://github.com/unsass/selector/commit/ccb922e))
23
+ * chore(deps): bump to `stylelint-config-unsass` 2.2.0 ([04e20fa](https://github.com/unsass/selector/commit/04e20fa))
24
+ * chore(deps): clean `package-lock.json` ([65d4a3d](https://github.com/unsass/selector/commit/65d4a3d))
25
+ * chore(deps): prevent dependencies vulnerabilities ([b3fbab9](https://github.com/unsass/selector/commit/b3fbab9))
26
+ * test(deps): switch from jest to vitest ([8c3ed03](https://github.com/unsass/selector/commit/8c3ed03))
27
+
28
+ ## [1.3.0](https://github.com/unsass/selector/compare/v1.2.0...v1.3.0) (2023-09-11)
29
+
30
+
31
+ ### Features
32
+
33
+ * **create:** add list option for `$scope` parameter ([ebd78c1](https://github.com/unsass/selector/commit/ebd78c1705a2271b4d8bad8b2441936abc928284))
34
+
35
+
36
+ ### Build System
37
+
38
+ * **deps:** bump to `sass` 1.66.1 ([b9ff3d5](https://github.com/unsass/selector/commit/b9ff3d5ccad6ab1a5fba427cfdc753a09f50418d))
39
+ * **deps:** prevent dependencies vulnerabilities ([610177d](https://github.com/unsass/selector/commit/610177d035c8d255e836846fe4a5b7c9be932c08))
40
+
5
41
  ## [1.2.0](https://github.com/unsass/selector/compare/v1.1.0...v1.2.0) (2023-03-20)
6
42
 
7
43
 
package/package.json CHANGED
@@ -1,39 +1,36 @@
1
1
  {
2
2
  "name": "@unsass/selector",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Sass functions and mixins to manage CSS selectors.",
5
+ "type": "module",
5
6
  "scripts": {
6
7
  "lint:css": "stylelint --fix \"**/*.scss\"",
7
8
  "lint": "npm-run-all --parallel lint:*",
8
- "test": "jest",
9
+ "test": "vitest",
9
10
  "prepare": "husky install",
10
11
  "release": "semantic-release"
11
12
  },
12
13
  "engines": {
13
- "node": ">=16.0.0",
14
- "npm": ">=8.0.0"
14
+ "node": ">=18"
15
15
  },
16
16
  "sass": "index.scss",
17
17
  "devDependencies": {
18
- "@commitlint/cli": "^17.4.4",
19
- "@commitlint/config-conventional": "^17.4.4",
20
- "@semantic-release/changelog": "^6.0.2",
18
+ "@commitlint/cli": "^20.3.0",
19
+ "@commitlint/config-conventional": "^20.3.0",
20
+ "@semantic-release/changelog": "^6.0.3",
21
21
  "@semantic-release/git": "^10.0.1",
22
- "glob": "^7.2.0",
23
- "husky": "^8.0.3",
24
- "jest": "^29.5.0",
25
- "jest-environment-node-single-context": "^29.0.0",
26
- "jest-junit": "^15.0.0",
22
+ "husky": "^9.1.7",
27
23
  "npm-run-all": "^4.1.5",
28
- "sass-true": "^7.0.0",
29
- "semantic-release": "^20.1.3",
30
- "stylelint": "^15.3.0",
31
- "stylelint-config-unsass": "^1.0.1"
24
+ "sass-true": "^10.1.0",
25
+ "semantic-release": "^25.0.2",
26
+ "stylelint": "^16.26.1",
27
+ "stylelint-config-unsass": "^2.2.0",
28
+ "vitest": "^4.0.16"
32
29
  },
33
30
  "dependencies": {
34
31
  "@unsass/string": "^1.4.2",
35
32
  "@unsass/types": "^1.0.2",
36
- "sass": "^1.53.0"
33
+ "sass": "^1.97.1"
37
34
  },
38
35
  "keywords": [
39
36
  "sass",
@@ -31,7 +31,7 @@
31
31
  /// @example - scss
32
32
  /// $selector: pseudo-class(".foo", "before");
33
33
  /// // ".foo::before"
34
- //
34
+ ///
35
35
  /// @access public
36
36
  ///
37
37
  @function pseudo-element($selector, $pseudo-element) {
@@ -42,7 +42,7 @@
42
42
  /// @example - scss
43
43
  /// $selector: to-id("foo");
44
44
  /// // "#foo"
45
- //
45
+ ///
46
46
  /// @access public
47
47
  ///
48
48
  @function to-id($selector) {
package/src/_mixins.scss CHANGED
@@ -50,7 +50,7 @@
50
50
  /// }
51
51
  ///
52
52
  /// @param {string} $selector - Selector name.
53
- /// @param {string} $scope - Selector affix value.
53
+ /// @param {string, list} $scope - Selector affix value.
54
54
  /// @param {string} $separator - Selector affix separator.
55
55
  /// @param {string} $pseudo-class - Selector pseudo-class.
56
56
  /// @param {string} $pseudo-element - Selector pseudo-element.
@@ -63,13 +63,13 @@
63
63
  ///
64
64
  @mixin create($selector, $scope: null, $separator: ":", $suffix: false, $pseudo-class: null, $pseudo-element: null, $root: false) {
65
65
  @if $pseudo-class and $suffix {
66
- @error "You cannot add a suffix with a selector that already has a pseudo-class."
66
+ @error "You cannot add a suffix with a selector that already has a pseudo-class.";
67
67
  } @else if $pseudo-element and $suffix {
68
- @error "You cannot add a suffix with a selector that already has a pseudo-element."
68
+ @error "You cannot add a suffix with a selector that already has a pseudo-element.";
69
69
  }
70
70
 
71
- $selector: if(type.is-list($selector), "#{list.nth($selector, 1)}", $selector);
72
- $class-selector: string.slice($selector, 1, 1) == ".";
71
+ $selector: if(sass(type.is-list($selector)): "#{list.nth($selector, 1)}"; else: $selector);
72
+ $class-selector: string.slice($selector, 1, 1) == ".";
73
73
 
74
74
  @if $class-selector {
75
75
  $selector: string.slice($selector, 2);
@@ -90,15 +90,39 @@
90
90
  ///
91
91
 
92
92
  @if $scope and not $suffix {
93
- @if type.is-number(string.to-number(string.slice($scope, 1, $end-at: 1))) {
94
- $scope: string.replace(\3 #{string.unquote($scope)}, " ");
93
+ $class: "";
94
+
95
+ @if type.is-list($scope) {
96
+ @each $key in $scope {
97
+ @if type.is-number(string.to-number(string.slice($key, 1, $end-at: 1))) {
98
+ $key: string.replace(\3 #{string.unquote($key)}, " ");
99
+ }
100
+
101
+ $class: $class + "#{$key}\\#{$separator}";
102
+ }
103
+ } @else {
104
+ @if type.is-number(string.to-number(string.slice($scope, 1, $end-at: 1))) {
105
+ $scope: string.replace(\3 #{string.unquote($scope)}, " ");
106
+ }
107
+
108
+ $class: "#{$scope}\\#{$separator}";
95
109
  }
96
110
 
97
- $selector: selector.append("#{$scope}\\#{$separator}", $selector);
111
+ $selector: selector.append($class, $selector);
98
112
  }
99
113
 
100
114
  @if $scope and $suffix {
101
- $selector: selector.append($selector, "\\#{$separator}#{$scope}");
115
+ $class: "";
116
+
117
+ @if type.is-list($scope) {
118
+ @each $key in $scope {
119
+ $class: $class + "\\#{$separator}#{$key}";
120
+ }
121
+ } @else {
122
+ $class: "\\#{$separator}#{$scope}";
123
+ }
124
+
125
+ $selector: selector.append($selector, $class);
102
126
  }
103
127
 
104
128
  ///