ember-style-modifier 4.4.0 → 4.5.1

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
@@ -26,6 +26,25 @@ argument. Property names are supported in dasherized as well as in camelCase
26
26
  spelling. Value must be a string or `undefined`. You may set a priority by
27
27
  adding an `"!important"` suffix.
28
28
 
29
+ ```gjs
30
+ import { style } from 'ember-style-modifier';
31
+
32
+ <p
33
+ {{style
34
+ border="1px"
35
+ padding="1em !important"
36
+ }}
37
+ >
38
+ </p>
39
+
40
+ <p
41
+ {{style
42
+ (hash border="1px" padding="1em !important")
43
+ }}
44
+ >
45
+ </p>
46
+ ```
47
+
29
48
  ```hbs
30
49
  <p
31
50
  {{style
package/addon-main.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
- const { addonV1Shim } = require("@embroider/addon-shim");
3
+ const { addonV1Shim } = require('@embroider/addon-shim');
4
4
  module.exports = addonV1Shim(__dirname);
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
+
1
2
  export { default } from './modifiers/style.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,4 @@
1
+
1
2
  import Modifier from 'ember-modifier';
2
3
  import { dasherize } from '@ember/string';
3
4
  import { assert } from '@ember/debug';
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","sources":["../../src/modifiers/style.ts"],"sourcesContent":["import Modifier from 'ember-modifier';\nimport { dasherize } from '@ember/string';\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\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","compileStyles","positional","named","filter","map","obj","Object","entries","k","v","dasherize","flat","StyleModifier","Modifier","existingStyles","Set","setStyles","element","newStyles","rulesToRemove","clear","forEach","property","value","assert","typeOf","priority","includes","replace","style","setProperty","delete","add","rule","removeProperty","modify"],"mappings":";;;;;AAMA;AACA;AACA;AACA;;AAMA,SAASA,QAAQA,CAACC,CAAU,EAAW;EACrC,OAAO,OAAOA,CAAC,KAAK,QAAQ,IAAIC,OAAO,CAACD,CAAC,CAAC,CAAA;AAC5C,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,aAAaA,CACpBC,UAAuB,EACvBC,KAAgB,EACI;EACpB,OAAO,CAAC,GAAGD,UAAU,CAACE,MAAM,CAACN,QAAQ,CAAC,EAAEK,KAAK,CAAC,CAC3CE,GAAG,CAAEC,GAAG,IACPC,MAAM,CAACC,OAAO,CAACF,GAAG,CAAC,CAACD,GAAG,CACrB,CAAC,CAACI,CAAC,EAAEC,CAAC,CAAC,KAAK,CAACC,SAAS,CAACF,CAAC,CAAC,EAAEC,CAAC,CAC9B,CACF,CAAC,CACAE,IAAI,EAAE,CAAA;AACX,CAAA;AAUe,MAAMC,aAAa,SAASC,QAAQ,CAAyB;AAC1EC,EAAAA,cAAc,GAAgB,IAAIC,GAAG,EAAE,CAAA;AAEvCC,EAAAA,SAASA,CACPC,OAA0C,EAC1CC,SAA6B,EAC7B;IACA,MAAM;AAAEJ,MAAAA,cAAAA;AAAe,KAAC,GAAG,IAAI,CAAA;AAC/B,IAAA,MAAMK,aAA0B,GAAG,IAAIJ,GAAG,CAACD,cAAc,CAAC,CAAA;;AAE1D;IACAA,cAAc,CAACM,KAAK,EAAE,CAAA;IAEtBF,SAAS,CAACG,OAAO,CAAC,CAAC,CAACC,QAAQ,EAAEC,KAAK,CAAC,KAAK;MACvCC,MAAM,CACJ,CAAkCF,+BAAAA,EAAAA,QAAQ,CAAQC,KAAAA,EAAAA,KAAK,KAAKE,MAAM,CAChEF,KACF,CAAC,CAAK,GAAA,CAAA,GACJ,qEAAqE,EACvE,OAAOA,KAAK,KAAK,WAAW,IAAIE,MAAM,CAACF,KAAK,CAAC,KAAK,QACpD,CAAC,CAAA;;AAED;AACA;MACA,IAAIG,QAAQ,GAAG,EAAE,CAAA;MACjB,IAAIH,KAAK,IAAIA,KAAK,CAACI,QAAQ,CAAC,YAAY,CAAC,EAAE;AACzCD,QAAAA,QAAQ,GAAG,WAAW,CAAA;QACtBH,KAAK,GAAGA,KAAK,CAACK,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;AACzC,OAAA;;AAEA;MACAX,OAAO,CAACY,KAAK,CAACC,WAAW,CAACR,QAAQ,EAAEC,KAAK,EAAEG,QAAQ,CAAC,CAAA;;AAEpD;AACAP,MAAAA,aAAa,CAACY,MAAM,CAACT,QAAQ,CAAC,CAAA;;AAE9B;AACAR,MAAAA,cAAc,CAACkB,GAAG,CAACV,QAAQ,CAAC,CAAA;AAC9B,KAAC,CAAC,CAAA;;AAEF;AACAH,IAAAA,aAAa,CAACE,OAAO,CAAEY,IAAI,IAAKhB,OAAO,CAACY,KAAK,CAACK,cAAc,CAACD,IAAI,CAAC,CAAC,CAAA;AACrE,GAAA;AAEAE,EAAAA,MAAMA,CACJlB,OAA0C,EAC1ChB,UAA4B,EAC5BC,KAAgB,EAChB;IACA,IAAI,CAACc,SAAS,CAACC,OAAO,EAAEjB,aAAa,CAACC,UAAU,EAAEC,KAAK,CAAC,CAAC,CAAA;AAC3D,GAAA;AACF;;;;"}
1
+ {"version":3,"file":"style.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=template-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-registry.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-style-modifier",
3
- "version": "4.4.0",
3
+ "version": "4.5.1",
4
4
  "description": "{{style}} modifier to set an element's style using the CSSStyleDeclaration API.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -8,11 +8,15 @@
8
8
  "repository": "https://github.com/jelhan/ember-style-modifier",
9
9
  "license": "MIT",
10
10
  "author": "",
11
+ "imports": {
12
+ "#src/*": "./src/*"
13
+ },
11
14
  "exports": {
12
15
  ".": {
13
16
  "types": "./declarations/index.d.ts",
14
17
  "default": "./dist/index.js"
15
18
  },
19
+ "./*.css": "./dist/*.css",
16
20
  "./*": {
17
21
  "types": "./declarations/*.d.ts",
18
22
  "default": "./dist/*.js"
@@ -32,75 +36,82 @@
32
36
  "dist"
33
37
  ],
34
38
  "scripts": {
35
- "build": "concurrently 'npm:build:*'",
36
- "build:js": "rollup --config",
37
- "build:types": "glint --declaration",
38
- "lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
39
- "lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
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",
40
44
  "lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
41
45
  "lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
42
46
  "lint:js": "eslint . --cache",
43
47
  "lint:js:fix": "eslint . --fix",
44
48
  "lint:types": "glint",
45
- "prepack": "pnpm run build",
46
- "start": "concurrently 'npm:start:*'",
47
- "start:js": "rollup --config --watch --no-watch.clearScreen",
48
- "start:types": "glint --declaration --watch",
49
- "test": "echo 'A v2 addon does not have tests, run tests in test-app'",
50
- "prepare": "pnpm run build"
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"
51
53
  },
52
54
  "dependencies": {
53
- "@embroider/addon-shim": "^1.8.7",
54
- "decorator-transforms": "^2.0.0",
55
+ "@embroider/addon-shim": "^1.10.0",
55
56
  "csstype": "^3.1.3",
57
+ "decorator-transforms": "^2.3.0",
56
58
  "ember-modifier": "^3.2.7 || ^4.0.0"
57
59
  },
58
60
  "devDependencies": {
59
- "@babel/core": "^7.23.6",
60
- "@babel/plugin-transform-typescript": "^7.23.6",
61
- "@babel/runtime": "^7.17.0",
62
- "@embroider/addon-dev": "^5.0.0",
63
- "@glint/core": "^1.2.1",
64
- "@glint/environment-ember-loose": "^1.2.1",
65
- "@glint/environment-ember-template-imports": "^1.2.2",
66
- "@glint/template": "^1.2.2",
67
- "@rollup/plugin-babel": "^6.0.4",
68
- "@tsconfig/ember": "^3.0.2",
69
- "@types/ember": "^4.0.10",
70
- "@types/ember__application": "^4.0.10",
71
- "@types/ember__array": "^4.0.9",
72
- "@types/ember__component": "^4.0.21",
73
- "@types/ember__controller": "^4.0.11",
74
- "@types/ember__debug": "^4.0.7",
75
- "@types/ember__destroyable": "^4.0.4",
76
- "@types/ember__engine": "^4.0.10",
77
- "@types/ember__error": "^4.0.5",
78
- "@types/ember__helper": "^4.0.5",
79
- "@types/ember__modifier": "^4.0.8",
80
- "@types/ember__object": "^4.0.11",
81
- "@types/ember__owner": "^4.0.8",
82
- "@types/ember__polyfills": "^4.0.5",
83
- "@types/ember__routing": "^4.0.19",
84
- "@types/ember__runloop": "^4.0.8",
85
- "@types/ember__service": "^4.0.8",
86
- "@types/ember__string": "^3.16.3",
87
- "@types/ember__template": "^4.0.5",
88
- "@types/ember__test": "^4.0.5",
89
- "@types/ember__utils": "^4.0.6",
90
- "@typescript-eslint/eslint-plugin": "^7.0.0",
91
- "@typescript-eslint/parser": "^7.0.0",
92
- "babel-plugin-ember-template-compilation": "^2.2.1",
93
- "concurrently": "^8.2.2",
94
- "ember-template-lint": "^6.0.0",
95
- "eslint": "^8.56.0",
96
- "eslint-config-prettier": "^9.1.0",
97
- "eslint-plugin-ember": "^12.0.0",
98
- "eslint-plugin-n": "^17.0.0",
99
- "eslint-plugin-prettier": "^5.0.1",
100
- "prettier": "^3.1.1",
101
- "prettier-plugin-ember-template-tag": "^2.0.0",
102
- "rollup": "^4.9.1",
103
- "typescript": "^5.3.3"
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",
75
+ "@glimmer/component": "2.0.0",
76
+ "@glint/core": "2.0.0-alpha.4",
77
+ "@glint/environment-ember-loose": "2.0.0-alpha.3",
78
+ "@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",
83
+ "@types/qunit": "2.19.13",
84
+ "babel-plugin-ember-template-compilation": "3.0.1",
85
+ "concurrently": "9.2.1",
86
+ "ember-qunit": "9.0.3",
87
+ "ember-resolver": "13.1.1",
88
+ "ember-source": "6.6.0",
89
+ "ember-template-lint": "7.9.3",
90
+ "eslint": "9.34.0",
91
+ "eslint-config-prettier": "10.1.8",
92
+ "eslint-plugin-ember": "12.7.3",
93
+ "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",
99
+ "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"
107
+ },
108
+ "peerDependencies": {
109
+ "@ember/string": "^3.1.1 || ^4.0.0"
110
+ },
111
+ "packageManager": "pnpm@10.15.0+sha512.486ebc259d3e999a4e8691ce03b5cac4a71cbeca39372a9b762cb500cfdf0873e2cb16abe3d951b1ee2cf012503f027b98b6584e4df22524e0c7450d9ec7aa7b",
112
+ "engines": {
113
+ "node": "18.* || >= 20",
114
+ "pnpm": ">= 10.*"
104
115
  },
105
116
  "publishConfig": {
106
117
  "registry": "https://registry.npmjs.org"
@@ -116,8 +127,19 @@
116
127
  "./modifiers/style.js": "./dist/_app_/modifiers/style.js"
117
128
  }
118
129
  },
119
- "peerDependencies": {
120
- "@ember/string": "^3.1.1 || ^4.0.0",
121
- "ember-source": "^3.28.0 || ^4.0.0 || >=5.0.0"
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
+ }
122
144
  }
123
145
  }