ember-style-modifier 4.5.1 → 4.6.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/README.md CHANGED
@@ -10,8 +10,7 @@ This allows to set custom CSS of an element without requiring a [Content Securit
10
10
  ## Compatibility
11
11
 
12
12
  * Ember.js v3.28 or above
13
- * Ember CLI v3.28 or above
14
- * Node.js v18 or above
13
+ * Embroider or ember-auto-import v2
15
14
 
16
15
  ## Installation
17
16
 
@@ -27,7 +26,7 @@ spelling. Value must be a string or `undefined`. You may set a priority by
27
26
  adding an `"!important"` suffix.
28
27
 
29
28
  ```gjs
30
- import { style } from 'ember-style-modifier';
29
+ import style from 'ember-style-modifier';
31
30
 
32
31
  <p
33
32
  {{style
@@ -1 +1 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/modifiers/style.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAItC,OAAO,KAAK,KAAK,GAAG,MAAM,SAAS,CAAC;AAMpC,KAAK,SAAS,GACV,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GACvB,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAC7B;IAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,MAAM,EAAE,GAAG,MAAM,CAAA;CAAE,CAAC;AAgC9C,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,GAAG,qBAAqB,CAAC;IACzC,IAAI,EAAE;QACJ,UAAU,EAAE,SAAS,EAAE,CAAC;QACxB,KAAK,EAAE,SAAS,CAAC;KAClB,CAAC;CACH;AAED,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,QAAQ,CAAC,sBAAsB,CAAC;IACzE,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IAExC,SAAS,CACP,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,EAC1C,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;IAuC/B,MAAM,CACJ,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,EAC1C,UAAU,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAC5B,KAAK,EAAE,SAAS;CAInB"}
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/modifiers/style.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,OAAO,KAAK,KAAK,GAAG,MAAM,SAAS,CAAC;AAMpC,KAAK,SAAS,GACV,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GACvB,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAC7B;IAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,MAAM,EAAE,GAAG,MAAM,CAAA;CAAE,CAAC;AAuC9C,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,GAAG,qBAAqB,CAAC;IACzC,IAAI,EAAE;QACJ,UAAU,EAAE,SAAS,EAAE,CAAC;QACxB,KAAK,EAAE,SAAS,CAAC;KAClB,CAAC;CACH;AAED,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,QAAQ,CAAC,sBAAsB,CAAC;IACzE,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IAExC,SAAS,CACP,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,EAC1C,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;IAuC/B,MAAM,CACJ,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,EAC1C,UAAU,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAC5B,KAAK,EAAE,SAAS;CAInB"}
package/dist/index.js CHANGED
@@ -1,3 +1,2 @@
1
-
2
1
  export { default } from './modifiers/style.js';
3
2
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,4 @@
1
-
2
1
  import Modifier from 'ember-modifier';
3
- import { dasherize } from '@ember/string';
4
2
  import { assert } from '@ember/debug';
5
3
  import { typeOf } from '@ember/utils';
6
4
 
@@ -12,6 +10,11 @@ import { typeOf } from '@ember/utils';
12
10
  function isObject(o) {
13
11
  return typeof o === 'object' && Boolean(o);
14
12
  }
13
+ const DASHERIZE_REGEX = /([a-z\d])([A-Z])/g;
14
+ const DASHERIZE_REPLACEMENT = '$1-$2';
15
+ function dasherize(str) {
16
+ return str.replace(DASHERIZE_REGEX, DASHERIZE_REPLACEMENT).toLowerCase();
17
+ }
15
18
 
16
19
  /**
17
20
  * Returns a two-dimensional array, like:
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"style.js","sources":["../../src/modifiers/style.ts"],"sourcesContent":["import Modifier from 'ember-modifier';\nimport { assert } from '@ember/debug';\nimport { typeOf } from '@ember/utils';\nimport type * as CSS from 'csstype';\n\n// Cannot be typed as `Partial<CSSStyleDeclaration>` because `CSSStyleDeclaration`\n// interface does _not_ included dashed CSS property names. It only includes the\n// camelCase version of a CSS property.\n// https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1672\ntype CSSStyles =\n | Partial<CSS.Properties>\n | Partial<CSS.PropertiesHyphen>\n | { readonly [key: `--${string}`]: string };\n\nfunction isObject(o: unknown): boolean {\n return typeof o === 'object' && Boolean(o);\n}\n\nconst DASHERIZE_REGEX = /([a-z\\d])([A-Z])/g;\nconst DASHERIZE_REPLACEMENT = '$1-$2';\n\nfunction dasherize(str: string): string {\n return str.replace(DASHERIZE_REGEX, DASHERIZE_REPLACEMENT).toLowerCase();\n}\n\n/**\n * Returns a two-dimensional array, like:\n *\n * ```js\n * [\n * ['font-size', '16px'],\n * ['text-align', 'center'],\n * ['color', 'red']\n * ]\n * ```\n *\n * This data structure is slightly faster to process than an object / dictionary.\n */\nfunction compileStyles(\n positional: CSSStyles[],\n named: CSSStyles,\n): [string, string][] {\n return [...positional.filter(isObject), named]\n .map((obj) =>\n Object.entries(obj).map(\n ([k, v]) => [dasherize(k), v] as [string, string],\n ),\n )\n .flat();\n}\n\nexport interface StyleModifierSignature {\n Element: Element & ElementCSSInlineStyle;\n Args: {\n Positional: CSSStyles[];\n Named: CSSStyles;\n };\n}\n\nexport default class StyleModifier extends Modifier<StyleModifierSignature> {\n existingStyles: Set<string> = new Set();\n\n setStyles(\n element: StyleModifierSignature['Element'],\n newStyles: [string, string][],\n ) {\n const { existingStyles } = this;\n const rulesToRemove: Set<string> = new Set(existingStyles);\n\n // clear cache of existing styles\n existingStyles.clear();\n\n newStyles.forEach(([property, value]) => {\n assert(\n `Your given value for property '${property}' is ${value} (${typeOf(\n value,\n )}). ` +\n 'Accepted types are string and undefined. Please change accordingly.',\n typeof value === 'undefined' || typeOf(value) === 'string',\n );\n\n // priority must be specified as separate argument\n // value must not contain \"!important\"\n let priority = '';\n if (value && value.includes('!important')) {\n priority = 'important';\n value = value.replace('!important', '');\n }\n\n // update CSSOM\n element.style.setProperty(property, value, priority);\n\n // should not remove rules that have been updated in this cycle\n rulesToRemove.delete(property);\n\n // cache styles that have been set for potential clean-up when argument changes\n existingStyles.add(property);\n });\n\n // remove rules that were present in last cycle but aren't present in this one\n rulesToRemove.forEach((rule) => element.style.removeProperty(rule));\n }\n\n modify(\n element: StyleModifierSignature['Element'],\n positional: [CSSStyles] | [],\n named: CSSStyles,\n ) {\n this.setStyles(element, compileStyles(positional, named));\n }\n}\n"],"names":["isObject","o","Boolean","DASHERIZE_REGEX","DASHERIZE_REPLACEMENT","dasherize","str","replace","toLowerCase","compileStyles","positional","named","filter","map","obj","Object","entries","k","v","flat","StyleModifier","Modifier","existingStyles","Set","setStyles","element","newStyles","rulesToRemove","clear","forEach","property","value","assert","typeOf","priority","includes","style","setProperty","delete","add","rule","removeProperty","modify"],"mappings":";;;;AAKA;AACA;AACA;AACA;;AAMA,SAASA,QAAQA,CAACC,CAAU,EAAW;EACrC,OAAO,OAAOA,CAAC,KAAK,QAAQ,IAAIC,OAAO,CAACD,CAAC,CAAC;AA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,QAAQ,GAAG,EAAE;MACjB,IAAIH,KAAK,IAAIA,KAAK,CAACI,QAAQ,CAAC,YAAY,CAAC,EAAE;AACzCD,QAAAA,QAAQ,GAAG,WAAW;QACtBH,KAAK,GAAGA,KAAK,CAACxB,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACzC,MAAA;;AAEA;MACAkB,OAAO,CAACW,KAAK,CAACC,WAAW,CAACP,QAAQ,EAAEC,KAAK,EAAEG,QAAQ,CAAC;;AAEpD;AACAP,MAAAA,aAAa,CAACW,MAAM,CAACR,QAAQ,CAAC;;AAE9B;AACAR,MAAAA,cAAc,CAACiB,GAAG,CAACT,QAAQ,CAAC;AAC9B,IAAA,CAAC,CAAC;;AAEF;AACAH,IAAAA,aAAa,CAACE,OAAO,CAAEW,IAAI,IAAKf,OAAO,CAACW,KAAK,CAACK,cAAc,CAACD,IAAI,CAAC,CAAC;AACrE,EAAA;AAEAE,EAAAA,MAAMA,CACJjB,OAA0C,EAC1Cf,UAA4B,EAC5BC,KAAgB,EAChB;IACA,IAAI,CAACa,SAAS,CAACC,OAAO,EAAEhB,aAAa,CAACC,UAAU,EAAEC,KAAK,CAAC,CAAC;AAC3D,EAAA;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-style-modifier",
3
- "version": "4.5.1",
3
+ "version": "4.6.0",
4
4
  "description": "{{style}} modifier to set an element's style using the CSSStyleDeclaration API.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -35,22 +35,6 @@
35
35
  "declarations",
36
36
  "dist"
37
37
  ],
38
- "scripts": {
39
- "build": "rollup --config",
40
- "format": "prettier . --cache --write",
41
- "lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
42
- "lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefixColors auto && pnpm run format",
43
- "lint:format": "prettier . --cache --check",
44
- "lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
45
- "lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
46
- "lint:js": "eslint . --cache",
47
- "lint:js:fix": "eslint . --fix",
48
- "lint:types": "glint",
49
- "prepack": "rollup --config",
50
- "release": "release-it",
51
- "start": "vite dev",
52
- "test": "vite build --mode=development --out-dir dist-tests && testem --file testem.cjs ci --port 0"
53
- },
54
38
  "dependencies": {
55
39
  "@embroider/addon-shim": "^1.10.0",
56
40
  "csstype": "^3.1.3",
@@ -58,57 +42,51 @@
58
42
  "ember-modifier": "^3.2.7 || ^4.0.0"
59
43
  },
60
44
  "devDependencies": {
61
- "@babel/core": "7.28.3",
62
- "@babel/eslint-parser": "7.28.0",
63
- "@babel/plugin-transform-typescript": "7.28.0",
64
- "@babel/runtime": "7.28.3",
65
- "@ember/app-tsconfig": "1.0.3",
66
- "@ember/library-tsconfig": "1.1.3",
67
- "@ember/string": "4.0.1",
68
- "@ember/test-helpers": "5.2.2",
69
- "@embroider/addon-dev": "8.1.0",
70
- "@embroider/compat": "4.1.2",
71
- "@embroider/core": "4.1.3",
72
- "@embroider/macros": "1.18.1",
73
- "@embroider/vite": "1.1.6",
74
- "@eslint/js": "9.34.0",
45
+ "@babel/core": "7.29.0",
46
+ "@babel/eslint-parser": "7.28.6",
47
+ "@babel/plugin-transform-typescript": "7.28.6",
48
+ "@babel/runtime": "7.29.2",
49
+ "@ember/app-tsconfig": "2.0.0",
50
+ "@ember/library-tsconfig": "2.0.0",
51
+ "@ember/test-helpers": "5.4.1",
52
+ "@embroider/addon-dev": "8.3.0",
53
+ "@embroider/compat": "4.1.17",
54
+ "@embroider/core": "4.4.7",
55
+ "@embroider/macros": "1.20.2",
56
+ "@embroider/vite": "1.7.2",
57
+ "@eslint/js": "9.39.4",
75
58
  "@glimmer/component": "2.0.0",
76
- "@glint/core": "2.0.0-alpha.4",
59
+ "@glint/core": "2.0.0-alpha.11",
77
60
  "@glint/environment-ember-loose": "2.0.0-alpha.3",
78
61
  "@glint/environment-ember-template-imports": "2.0.0-alpha.3",
79
- "@glint/template": "1.6.0-alpha.2",
80
- "@glint/tsserver-plugin": "2.0.0-alpha.4",
81
- "@release-it-plugins/lerna-changelog": "8.0.1",
82
- "@rollup/plugin-babel": "6.0.4",
62
+ "@glint/template": "1.7.7",
63
+ "@glint/tsserver-plugin": "2.4.0",
64
+ "@rollup/plugin-babel": "7.0.0",
83
65
  "@types/qunit": "2.19.13",
84
- "babel-plugin-ember-template-compilation": "3.0.1",
66
+ "babel-plugin-ember-template-compilation": "4.0.0",
85
67
  "concurrently": "9.2.1",
86
- "ember-qunit": "9.0.3",
87
- "ember-resolver": "13.1.1",
88
- "ember-source": "6.6.0",
68
+ "ember-qunit": "9.0.4",
69
+ "ember-resolver": "13.2.0",
70
+ "ember-source": "6.12.0",
89
71
  "ember-template-lint": "7.9.3",
90
- "eslint": "9.34.0",
72
+ "eslint": "9.39.4",
91
73
  "eslint-config-prettier": "10.1.8",
92
- "eslint-plugin-ember": "12.7.3",
74
+ "eslint-plugin-ember": "12.7.5",
93
75
  "eslint-plugin-import": "2.32.0",
94
- "eslint-plugin-n": "17.21.3",
95
- "globals": "16.3.0",
96
- "prettier": "3.6.2",
97
- "prettier-plugin-ember-template-tag": "2.1.0",
98
- "qunit": "2.24.1",
76
+ "eslint-plugin-n": "17.24.0",
77
+ "globals": "17.4.0",
78
+ "prettier": "3.8.1",
79
+ "prettier-plugin-ember-template-tag": "2.1.3",
80
+ "qunit": "2.25.0",
99
81
  "qunit-dom": "3.5.0",
100
- "release-it": "19.0.4",
101
- "rollup": "4.48.1",
102
- "testem": "3.16.0",
103
- "tracked-built-ins": "4.0.0",
104
- "typescript": "5.9.2",
105
- "typescript-eslint": "8.40.0",
106
- "vite": "7.1.3"
82
+ "release-plan": "^0.18.0",
83
+ "rollup": "4.60.1",
84
+ "testem": "3.19.1",
85
+ "tracked-built-ins": "4.1.2",
86
+ "typescript": "6.0.2",
87
+ "typescript-eslint": "8.46.3",
88
+ "vite": "8.0.5"
107
89
  },
108
- "peerDependencies": {
109
- "@ember/string": "^3.1.1 || ^4.0.0"
110
- },
111
- "packageManager": "pnpm@10.15.0+sha512.486ebc259d3e999a4e8691ce03b5cac4a71cbeca39372a9b762cb500cfdf0873e2cb16abe3d951b1ee2cf012503f027b98b6584e4df22524e0c7450d9ec7aa7b",
112
90
  "engines": {
113
91
  "node": "18.* || >= 20",
114
92
  "pnpm": ">= 10.*"
@@ -127,19 +105,19 @@
127
105
  "./modifiers/style.js": "./dist/_app_/modifiers/style.js"
128
106
  }
129
107
  },
130
- "release-it": {
131
- "plugins": {
132
- "@release-it-plugins/lerna-changelog": {
133
- "infile": "CHANGELOG.md",
134
- "launchEditor": true
135
- }
136
- },
137
- "git": {
138
- "tagName": "v${version}"
139
- },
140
- "github": {
141
- "release": true,
142
- "tokenRef": "GITHUB_AUTH"
143
- }
108
+ "scripts": {
109
+ "build": "rollup --config",
110
+ "format": "prettier . --cache --write",
111
+ "lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
112
+ "lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefixColors auto && pnpm run format",
113
+ "lint:format": "prettier . --cache --check",
114
+ "lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
115
+ "lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
116
+ "lint:js": "eslint . --cache",
117
+ "lint:js:fix": "eslint . --fix",
118
+ "lint:types": "glint",
119
+ "release": "release-it",
120
+ "start": "vite dev",
121
+ "test": "vite build --mode=development --out-dir dist-tests && testem --file testem.cjs ci --port 0"
144
122
  }
145
- }
123
+ }