ember-css-modules 1.6.0 → 2.0.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/addon/helpers/local-class.js +10 -3
- package/addon/index.js +0 -1
- package/app/initializers/ensure-local-class-included.js +2 -2
- package/config/environment.js +2 -2
- package/index.js +49 -58
- package/lib/htmlbars-plugin/index.js +64 -68
- package/lib/htmlbars-plugin/utils.js +7 -7
- package/lib/modules-preprocessor.js +61 -58
- package/lib/output-styles-preprocessor.js +48 -57
- package/lib/plugin/registry.js +25 -11
- package/lib/resolve-path.js +37 -13
- package/lib/utils/normalize-postcss-plugins.js +1 -1
- package/package.json +57 -51
- package/.template-lintrc.js +0 -8
- package/addon/decorators.js +0 -168
- package/addon/extensions.js +0 -4
- package/addon/mixins/component-mixin.js +0 -111
- package/index.d.ts +0 -40
- package/lib/make-postcss-plugin.js +0 -18
- package/lib/postcss-module-order-directive.js +0 -29
- package/vendor/~ember-css-modules/ext.js +0 -2
package/package.json
CHANGED
|
@@ -1,62 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-css-modules",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "CSS Modules for ambitious applications",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "ember build",
|
|
6
|
+
"build": "ember build --environment=production",
|
|
7
|
+
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
|
|
8
|
+
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
|
|
7
9
|
"lint:hbs": "ember-template-lint .",
|
|
8
|
-
"lint:
|
|
10
|
+
"lint:hbs:fix": "ember-template-lint . --fix",
|
|
11
|
+
"lint:js": "eslint . --cache",
|
|
12
|
+
"lint:js:fix": "eslint . --fix",
|
|
9
13
|
"start": "ember server",
|
|
10
|
-
"test": "
|
|
11
|
-
"test:
|
|
12
|
-
"test:
|
|
14
|
+
"test": "npm-run-all lint test:node test:ember",
|
|
15
|
+
"test:ember": "ember test",
|
|
16
|
+
"test:ember-compatibility": "ember try:each",
|
|
17
|
+
"test:node": "qunit tests-node/**/*-test.js"
|
|
13
18
|
},
|
|
14
19
|
"engines": {
|
|
15
|
-
"node": "
|
|
20
|
+
"node": "12.* || 14.* || >= 16"
|
|
16
21
|
},
|
|
17
22
|
"bugs": {
|
|
18
23
|
"url": "https://github.com/salsify/ember-css-modules/issues"
|
|
19
24
|
},
|
|
20
25
|
"homepage": "https://github.com/salsify/ember-css-modules#readme",
|
|
21
26
|
"devDependencies": {
|
|
22
|
-
"@ember-
|
|
23
|
-
"@ember/
|
|
24
|
-
"
|
|
27
|
+
"@ember/optional-features": "^2.0.0",
|
|
28
|
+
"@ember/test-helpers": "^2.4.2",
|
|
29
|
+
"@embroider/test-setup": "^0.43.5",
|
|
30
|
+
"@glimmer/component": "^1.0.4",
|
|
31
|
+
"@glimmer/tracking": "^1.0.4",
|
|
32
|
+
"babel-eslint": "^10.1.0",
|
|
25
33
|
"broccoli-plugin": "^1.3.1",
|
|
26
34
|
"console-ui": "^2.2.2",
|
|
27
|
-
"ember-
|
|
28
|
-
"ember-
|
|
29
|
-
"ember-cli": "
|
|
30
|
-
"ember-cli-
|
|
31
|
-
"ember-cli-dependency-checker": "^3.0.0",
|
|
32
|
-
"ember-cli-htmlbars-inline-precompile": "^1.0.3",
|
|
33
|
-
"ember-cli-inject-live-reload": "^1.8.2",
|
|
34
|
-
"ember-cli-qunit": "^4.3.2",
|
|
35
|
-
"ember-cli-sri": "^2.1.1",
|
|
36
|
-
"ember-cli-test-loader": "^2.2.0",
|
|
37
|
-
"ember-cli-uglify": "^2.1.0",
|
|
38
|
-
"ember-compatibility-helpers": "^1.0.2",
|
|
39
|
-
"ember-decorators-polyfill": "^1.0.3",
|
|
35
|
+
"ember-auto-import": "^2.2.4",
|
|
36
|
+
"ember-cli": "~3.28.4",
|
|
37
|
+
"ember-cli-dependency-checker": "^3.2.0",
|
|
38
|
+
"ember-cli-inject-live-reload": "^2.1.0",
|
|
40
39
|
"ember-disable-prototype-extensions": "^1.1.3",
|
|
41
|
-
"ember-
|
|
42
|
-
"ember-
|
|
43
|
-
"ember-
|
|
44
|
-
"ember-resolver": "^
|
|
45
|
-
"ember-
|
|
46
|
-
"ember-source": "
|
|
47
|
-
"ember-
|
|
48
|
-
"ember-
|
|
49
|
-
"
|
|
50
|
-
"eslint": "^
|
|
51
|
-
"eslint-plugin-ember": "^5.
|
|
52
|
-
"eslint-plugin-node": "^
|
|
40
|
+
"ember-load-initializers": "^2.1.2",
|
|
41
|
+
"ember-page-title": "^6.2.2",
|
|
42
|
+
"ember-qunit": "^5.1.4",
|
|
43
|
+
"ember-resolver": "^8.0.3",
|
|
44
|
+
"ember-source": "~3.28.0",
|
|
45
|
+
"ember-source-channel-url": "^3.0.0",
|
|
46
|
+
"ember-template-lint": "^3.6.0",
|
|
47
|
+
"ember-try": "^1.4.0",
|
|
48
|
+
"eslint": "^7.32.0",
|
|
49
|
+
"eslint-config-prettier": "^8.3.0",
|
|
50
|
+
"eslint-plugin-ember": "^10.5.4",
|
|
51
|
+
"eslint-plugin-node": "^11.1.0",
|
|
52
|
+
"eslint-plugin-prettier": "^3.4.1",
|
|
53
|
+
"eslint-plugin-qunit": "^6.2.0",
|
|
53
54
|
"loader.js": "^4.7.0",
|
|
55
|
+
"npm-run-all": "^4.1.5",
|
|
54
56
|
"postcss-color-rebeccapurple": "^6.0.0",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
+
"prettier": "^2.3.2",
|
|
58
|
+
"qunit": "^2.17.2",
|
|
59
|
+
"qunit-dom": "^2.0.0",
|
|
57
60
|
"sinon": "^4.3.0",
|
|
58
61
|
"template-stuff": "link:tests/dummy/lib/template-stuff",
|
|
59
|
-
"webpack": "^
|
|
62
|
+
"webpack": "^5.64.1"
|
|
60
63
|
},
|
|
61
64
|
"keywords": [
|
|
62
65
|
"ember-addon",
|
|
@@ -70,22 +73,22 @@
|
|
|
70
73
|
"author": "Dan Freeman",
|
|
71
74
|
"dependencies": {
|
|
72
75
|
"broccoli-bridge": "^1.0.0",
|
|
73
|
-
"broccoli-concat": "^
|
|
74
|
-
"broccoli-css-modules": "^0.
|
|
75
|
-
"broccoli-funnel": "^
|
|
76
|
-
"broccoli-merge-trees": "^2.0
|
|
77
|
-
"broccoli-postcss": "^
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"ember-cli-
|
|
81
|
-
"ember-cli-htmlbars": "^3.0.0",
|
|
82
|
-
"ember-cli-version-checker": "^2.1.0",
|
|
76
|
+
"broccoli-concat": "^4.2.5",
|
|
77
|
+
"broccoli-css-modules": "^0.8.0",
|
|
78
|
+
"broccoli-funnel": "^3.0.8",
|
|
79
|
+
"broccoli-merge-trees": "^4.2.0",
|
|
80
|
+
"broccoli-postcss": "^6.0.0",
|
|
81
|
+
"debug": "^4.3.2",
|
|
82
|
+
"ember-cli-babel": "^7.26.6",
|
|
83
|
+
"ember-cli-htmlbars": "^6.0.0",
|
|
83
84
|
"ensure-posix-path": "^1.0.2",
|
|
84
85
|
"hash-string": "^1.0.0",
|
|
85
86
|
"lodash.merge": "^4.6.1",
|
|
86
|
-
"postcss": "^
|
|
87
|
-
"
|
|
88
|
-
|
|
87
|
+
"postcss": "^8.0.0",
|
|
88
|
+
"toposort": "^2.0.2"
|
|
89
|
+
},
|
|
90
|
+
"ember": {
|
|
91
|
+
"edition": "octane"
|
|
89
92
|
},
|
|
90
93
|
"ember-addon": {
|
|
91
94
|
"configPath": "tests/dummy/config",
|
|
@@ -100,5 +103,8 @@
|
|
|
100
103
|
"ember-cli-stylus",
|
|
101
104
|
"ember-cli-postcss"
|
|
102
105
|
]
|
|
106
|
+
},
|
|
107
|
+
"volta": {
|
|
108
|
+
"node": "16.13.0"
|
|
103
109
|
}
|
|
104
110
|
}
|
package/.template-lintrc.js
DELETED
package/addon/decorators.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The implementation of these decorators is based on the original work of the
|
|
3
|
-
ember-osf-web project, released under the Apache License 2.0:
|
|
4
|
-
|
|
5
|
-
https://github.com/CenterForOpenScience/ember-osf-web/blob/4675920c4d53e60c62eed7a87ea84e0f4c5ab018/app/decorators/css-modules.ts
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { get } from '@ember/object';
|
|
9
|
-
import { assert } from '@ember/debug';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
Class decorator which specifies the local class names to be applied to a
|
|
13
|
-
component. This replaces the `localClassNames` property on components in the
|
|
14
|
-
traditional Ember object model.
|
|
15
|
-
|
|
16
|
-
```js
|
|
17
|
-
@localClassNames('a-static-class', 'another-static-class')
|
|
18
|
-
export default class ClassNamesDemoComponent extends Component {}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
@param {...string} classNames - The list of local classes to be applied to the component
|
|
22
|
-
*/
|
|
23
|
-
export const localClassNames = (...classNames) => (...desc) => {
|
|
24
|
-
assert(
|
|
25
|
-
`The @localClassNames decorator must be provided strings, received: ${classNames}`,
|
|
26
|
-
classNames.every(className => typeof className === 'string')
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
if (isStage1ClassDescriptor(desc)) {
|
|
30
|
-
collapseAndMerge(desc[0].prototype, 'localClassNames', ...classNames);
|
|
31
|
-
} else {
|
|
32
|
-
desc[0].finisher = target => {
|
|
33
|
-
collapseAndMerge(target.prototype, 'localClassNames', ...classNames);
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
Decorator which indicates that the field or computed should be bound to the
|
|
40
|
-
component local class names. This replaces `localClassNameBindings` by
|
|
41
|
-
directly allowing you to specify which properties should be bound.
|
|
42
|
-
|
|
43
|
-
```js
|
|
44
|
-
export default class ClassNameDemoComponent extends Component {
|
|
45
|
-
// Adds 'bound-field' class, if true
|
|
46
|
-
@localClassName boundField = true;
|
|
47
|
-
|
|
48
|
-
// With provided true/false class names
|
|
49
|
-
@localClassName('active', 'inactive') isActive = true;
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
@function
|
|
53
|
-
@param {string} truthyName? - The local class to be applied if the value the
|
|
54
|
-
field is truthy, defaults to the name of the
|
|
55
|
-
field.
|
|
56
|
-
@param {string} falsyName? - The class to be applied if the value of the field
|
|
57
|
-
is falsy.
|
|
58
|
-
*/
|
|
59
|
-
export const localClassName = (...params) => {
|
|
60
|
-
if (isFieldDescriptor(params)) {
|
|
61
|
-
return localClassName()(...params);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return (...desc) => {
|
|
65
|
-
assert(
|
|
66
|
-
`The @localClassName decorator may only receive strings as parameters. Received: ${params}`,
|
|
67
|
-
params.every(className => typeof className === 'string')
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
if (isStage1FieldDescriptor(desc)) {
|
|
71
|
-
let [prototype, key, descriptor] = desc;
|
|
72
|
-
setUpLocalClassField(params, prototype, key, descriptor);
|
|
73
|
-
} else if (isStage2FieldDescriptor(desc)) {
|
|
74
|
-
desc[0].finisher = target => {
|
|
75
|
-
const { key, descriptor } = desc[0];
|
|
76
|
-
setUpLocalClassField(params, target.prototype, key, descriptor);
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
function setUpLocalClassField(params, prototype, key, descriptor) {
|
|
83
|
-
const binding = params.length > 0 ? `${key}:${params.join(':')}` : key;
|
|
84
|
-
|
|
85
|
-
collapseAndMerge(prototype, 'localClassNameBindings', binding);
|
|
86
|
-
|
|
87
|
-
if (descriptor) {
|
|
88
|
-
// Decorated fields are currently not configurable in Babel for some reason, so ensure
|
|
89
|
-
// that the field becomes configurable (else it messes with things)
|
|
90
|
-
descriptor.configurable = true;
|
|
91
|
-
|
|
92
|
-
// Decorated fields which don't have a getter or setter, but also no
|
|
93
|
-
// explicit `writable` flag, default to not being writable in Babel. Since
|
|
94
|
-
// by default fields _are_ writable and this decorator should not change
|
|
95
|
-
// that, we enable the `writable` flag in this specific case.
|
|
96
|
-
if (!('get' in descriptor || 'set' in descriptor || 'writable' in descriptor)) {
|
|
97
|
-
descriptor.writable = true;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Babel 6 provides a `null` initializer if one isn't set, but that can wind up
|
|
101
|
-
// overwriting passed-in values if they're specified.
|
|
102
|
-
// This is a no-op in Babel 7 (since `initializer` isn't part of the property descriptor)
|
|
103
|
-
// and can be dropped when we remove support for Babel 6
|
|
104
|
-
if (descriptor.initializer === null) {
|
|
105
|
-
descriptor.initializer = function() {
|
|
106
|
-
return get(this, key);
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function collapseAndMerge(prototype, property, ...items) {
|
|
113
|
-
collapseProto(prototype);
|
|
114
|
-
|
|
115
|
-
if (property in prototype) {
|
|
116
|
-
const parentElements = prototype[property];
|
|
117
|
-
items.unshift(...parentElements)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
prototype[property] = items;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// These utilities are from @ember-decorators/utils
|
|
124
|
-
// https://github.com/ember-decorators/ember-decorators/blob/f3e3d636a38d99992af326a1012d69bf10a2cb4c/packages/utils/addon/-private/class-field-descriptor.js
|
|
125
|
-
|
|
126
|
-
function isStage1ClassDescriptor(possibleDesc) {
|
|
127
|
-
let [target] = possibleDesc;
|
|
128
|
-
|
|
129
|
-
return (
|
|
130
|
-
possibleDesc.length === 1 &&
|
|
131
|
-
typeof target === 'function' &&
|
|
132
|
-
'prototype' in target &&
|
|
133
|
-
!target.__isComputedDecorator
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function isFieldDescriptor(possibleDesc) {
|
|
138
|
-
return isStage1FieldDescriptor(possibleDesc) || isStage2FieldDescriptor(possibleDesc);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function isStage2FieldDescriptor(possibleDesc) {
|
|
142
|
-
return possibleDesc && possibleDesc.toString() === '[object Descriptor]';
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function isStage1FieldDescriptor(possibleDesc) {
|
|
146
|
-
let [target, key, desc] = possibleDesc;
|
|
147
|
-
|
|
148
|
-
return (
|
|
149
|
-
possibleDesc.length === 3 &&
|
|
150
|
-
typeof target === 'object' &&
|
|
151
|
-
target !== null &&
|
|
152
|
-
typeof key === 'string' &&
|
|
153
|
-
((typeof desc === 'object' &&
|
|
154
|
-
desc !== null &&
|
|
155
|
-
'enumerable' in desc &&
|
|
156
|
-
'configurable' in desc) ||
|
|
157
|
-
desc === undefined) // TS compatibility
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function collapseProto(target) {
|
|
162
|
-
// We must collapse the superclass prototype to make sure that the `actions`
|
|
163
|
-
// object will exist. Since collapsing doesn't generally happen until a class is
|
|
164
|
-
// instantiated, we have to do it manually.
|
|
165
|
-
if (typeof target.constructor.proto === 'function') {
|
|
166
|
-
target.constructor.proto();
|
|
167
|
-
}
|
|
168
|
-
}
|
package/addon/extensions.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/* global require */
|
|
2
|
-
|
|
3
|
-
import { computed, defineProperty } from '@ember/object';
|
|
4
|
-
import Mixin from '@ember/object/mixin';
|
|
5
|
-
import { dasherize } from '@ember/string';
|
|
6
|
-
import { getOwner } from '@ember/application';
|
|
7
|
-
import { assert, deprecate } from '@ember/debug';
|
|
8
|
-
|
|
9
|
-
export default Mixin.create({
|
|
10
|
-
localClassNames: null,
|
|
11
|
-
localClassNameBindings: null,
|
|
12
|
-
|
|
13
|
-
concatenatedProperties: ['localClassNames', 'localClassNameBindings'],
|
|
14
|
-
|
|
15
|
-
init() {
|
|
16
|
-
this._super();
|
|
17
|
-
|
|
18
|
-
if (this.tagName === '') return;
|
|
19
|
-
|
|
20
|
-
this.classNameBindings = [
|
|
21
|
-
...this.classNameBindings,
|
|
22
|
-
...localClassNames(this),
|
|
23
|
-
LOCAL_CLASS_NAMES_CP,
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
if (this.localClassNameBindings.length) {
|
|
27
|
-
let value = localClassNamesCP(this.localClassNameBindings, this.get('__styles__'));
|
|
28
|
-
defineProperty(this, LOCAL_CLASS_NAMES_CP, value);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
__styles__: computed(function() {
|
|
33
|
-
let key = this._debugContainerKey;
|
|
34
|
-
if (!key) { return; }
|
|
35
|
-
|
|
36
|
-
let name = key.replace(/^component:/, '');
|
|
37
|
-
let layout = this.layout || getOwner(this).lookup(`template:components/${name}`);
|
|
38
|
-
assert(
|
|
39
|
-
`Unable to resolve localClassNames or localClassNameBindings for component ${name}, which has no ` +
|
|
40
|
-
`layout. You can fix this by either creating an empty template for your component or importing and ` +
|
|
41
|
-
`using the styles hash directly instead, e.g. \`classNames: styles['my-class']\`.`,
|
|
42
|
-
layout
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
deprecate(
|
|
46
|
-
'Support for `localClassNames`, `localClassNameBindings` and the `@localClassName` and `@localClassNames` ' +
|
|
47
|
-
'decorators will be removed in the next major release of ember-css-modules. The `' + name + '` component ' +
|
|
48
|
-
'uses one or more of these APIs. See the ECM 1.5.0 release notes for further details and migration options: ' +
|
|
49
|
-
'https://github.com/salsify/ember-css-modules/releases/tag/v1.5.0',
|
|
50
|
-
false,
|
|
51
|
-
{
|
|
52
|
-
id: 'ember-css-modules.classic-component-apis',
|
|
53
|
-
for: 'ember-css-modules',
|
|
54
|
-
until: '2.0.0',
|
|
55
|
-
since: {
|
|
56
|
-
enabled: '1.5.0'
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
// Since https://github.com/emberjs/ember.js/pull/18096
|
|
62
|
-
if (typeof layout === 'function') layout = layout(getOwner(this));
|
|
63
|
-
|
|
64
|
-
// This is not public API and might break at any time...
|
|
65
|
-
let moduleName = (layout.meta || layout.referrer).moduleName.replace(/\.hbs$/, '');
|
|
66
|
-
if (/\/template$/.test(moduleName)) {
|
|
67
|
-
return tryLoad(moduleName.replace(/template$/, 'styles'));
|
|
68
|
-
} else if (/\/templates\//.test(moduleName)) {
|
|
69
|
-
return tryLoad(moduleName.replace('/templates/', '/styles/'));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return;
|
|
73
|
-
})
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
function tryLoad(path) {
|
|
77
|
-
if (require.has(path)) {
|
|
78
|
-
return require(path).default;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const LOCAL_CLASS_NAMES_CP = '__ecm_local_class_names__';
|
|
83
|
-
|
|
84
|
-
function localClassNames(component) {
|
|
85
|
-
return component.localClassNames.map(className => `__styles__.${className}`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function localClassNamesCP(localClassNameBindings, styles) {
|
|
89
|
-
let bindings = localClassNameBindings.map((binding) => {
|
|
90
|
-
let [property, trueStyle, falseStyle] = binding.split(':');
|
|
91
|
-
let trueClasses = styles[trueStyle || dasherize(property)] || '';
|
|
92
|
-
let falseClasses = styles[falseStyle] || '';
|
|
93
|
-
let isBoolean = !!trueStyle;
|
|
94
|
-
return { property, trueClasses, falseClasses, isBoolean };
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
return computed(...bindings.map(binding => binding.property), function() {
|
|
98
|
-
let classes = [];
|
|
99
|
-
|
|
100
|
-
bindings.forEach((binding) => {
|
|
101
|
-
let value = this.get(binding.property);
|
|
102
|
-
if (binding.isBoolean || typeof value !== 'string') {
|
|
103
|
-
classes.push(value ? binding.trueClasses : binding.falseClasses);
|
|
104
|
-
} else {
|
|
105
|
-
classes.push(value.split(/\s+/).map(key => styles[key]).join(' '));
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
return classes.join(' ');
|
|
110
|
-
});
|
|
111
|
-
}
|
package/index.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
Decorator which indicates that the field or computed should be bound to the
|
|
3
|
-
component local class names. This replaces `localClassNameBindings` by
|
|
4
|
-
directly allowing you to specify which properties should be bound.
|
|
5
|
-
|
|
6
|
-
```js
|
|
7
|
-
export default class ClassNameDemoComponent extends Component {
|
|
8
|
-
// Adds 'bound-field' class, if true
|
|
9
|
-
@localClassName boundField = true;
|
|
10
|
-
|
|
11
|
-
// With provided true/false class names
|
|
12
|
-
@localClassName('active', 'inactive') isActive = true;
|
|
13
|
-
}
|
|
14
|
-
```
|
|
15
|
-
@function
|
|
16
|
-
@param {string} truthyName? - The local class to be applied if the value the
|
|
17
|
-
field is truthy, defaults to the name of the
|
|
18
|
-
field.
|
|
19
|
-
@param {string} falsyName? - The class to be applied if the value of the field
|
|
20
|
-
is falsy.
|
|
21
|
-
*/
|
|
22
|
-
export function localClassName(
|
|
23
|
-
truthyName?: string,
|
|
24
|
-
falsyName?: string
|
|
25
|
-
): PropertyDecorator;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
Class decorator which specifies the local class names to be applied to a
|
|
29
|
-
component. This replaces the `localClassNames` property on components in the
|
|
30
|
-
traditional Ember object model.
|
|
31
|
-
|
|
32
|
-
```js
|
|
33
|
-
@localClassNames('a-static-class', 'another-static-class')
|
|
34
|
-
export default class ClassNamesDemoComponent extends Component {}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
@param {...string} classNames - The list of local classes to be applied to the component
|
|
38
|
-
*/
|
|
39
|
-
export function localClassNames(...classNames: string[]): ClassDecorator;
|
|
40
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const semver = require('semver');
|
|
2
|
-
const postcssVersion = require('postcss/package.json').version;
|
|
3
|
-
|
|
4
|
-
if (semver.lt(postcssVersion, '8.0.0')) {
|
|
5
|
-
module.exports = require('postcss').plugin;
|
|
6
|
-
} else {
|
|
7
|
-
module.exports = function(name, callback) {
|
|
8
|
-
let plugin = (options = {}) => {
|
|
9
|
-
let handler = callback(options);
|
|
10
|
-
return {
|
|
11
|
-
postcssPlugin: name,
|
|
12
|
-
Once: handler
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
plugin.postcss = true;
|
|
16
|
-
return plugin;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const ensurePosixPath = require('ensure-posix-path');
|
|
4
|
-
const makePostCSSPlugin = require('./make-postcss-plugin');
|
|
5
|
-
|
|
6
|
-
// Report all discovered @after-module rules in a module and strip them out of the source
|
|
7
|
-
module.exports = makePostCSSPlugin('ember-css-modules-ordering', (options) => {
|
|
8
|
-
return (css) => {
|
|
9
|
-
let dependencies = [];
|
|
10
|
-
let input = css.source.input;
|
|
11
|
-
let filePath = input.file.replace(input.rootPath + '/', '');
|
|
12
|
-
|
|
13
|
-
css.walkAtRules((rule) => {
|
|
14
|
-
if (rule.name !== 'after-module') { return; }
|
|
15
|
-
|
|
16
|
-
if (options.emitDeprecationWarning) {
|
|
17
|
-
let warning = '@after-module is deprecated; use `headerFiles` and `footerFiles` instead';
|
|
18
|
-
options.ui.writeDeprecateLine(`${filePath}:${rule.source.start.line} - ${warning}`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
dependencies.push(rule.params.replace(/^['"]|["']$/g, ''));
|
|
22
|
-
rule.remove();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
if (dependencies.length) {
|
|
26
|
-
options.updateDependencies(ensurePosixPath(css.source.input.file), dependencies);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
});
|