@inradius/solid-wc-css-mixin 1.0.2 → 1.0.4

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
@@ -1,5 +1,5 @@
1
1
  # @inradius/solid-wc-css-mixin
2
- ![npm version](https://img.shields.io/npm/v/@inradius/solid-wc-css-mixin) ![license](https://img.shields.io/npm/l/@inradius/solid-wc-css-mixin)
2
+ ![npm version](https://img.shields.io/npm/v/@inradius/solid-wc-css-mixin) ![CI Action](https://github.com/inradius/solid-wc-utils-monorepo/actions/workflows/ci.yml/badge.svg) ![license](https://img.shields.io/npm/l/@inradius/solid-wc-css-mixin)
3
3
 
4
4
  A lightweight mixin for [component-register](https://www.npmjs.com/package/component-register) that allows you to inject computed or inlined CSS directly into a Web Component's **Shadow Root** using Constructable Stylesheets.
5
5
 
@@ -45,4 +45,4 @@ The mixin creates a new `CSSStyleSheet` object and pushes it into the element's
45
45
  - **Peer Dependencies:** This package is designed to be used with `component-register`.
46
46
 
47
47
  ## License
48
- MIT © Travis
48
+ MIT
package/dist/index.cjs CHANGED
@@ -1 +1,15 @@
1
- "use strict";const o=require("component-register"),S=n=>o.createMixin(t=>{const{element:e}=t,r=new CSSStyleSheet;return"adoptedStyleSheets"in e.renderRoot&&(r.replaceSync(n),e.renderRoot.adoptedStyleSheets=[...e.renderRoot.adoptedStyleSheets,r]),{...t,element:e}});module.exports=S;
1
+ "use strict";
2
+ const componentRegister = require("component-register");
3
+ const withCSS = (styles) => componentRegister.createMixin((options) => {
4
+ const { element } = options;
5
+ const stylesheet = new CSSStyleSheet();
6
+ if ("adoptedStyleSheets" in element.renderRoot) {
7
+ stylesheet.replaceSync(styles);
8
+ element.renderRoot.adoptedStyleSheets = [
9
+ ...element.renderRoot.adoptedStyleSheets,
10
+ stylesheet
11
+ ];
12
+ }
13
+ return { ...options, element };
14
+ });
15
+ module.exports = withCSS;
package/dist/index.js CHANGED
@@ -1,11 +1,16 @@
1
- import { createMixin as S } from "component-register";
2
- const d = (r) => S((t) => {
3
- const { element: e } = t, o = new CSSStyleSheet();
4
- return "adoptedStyleSheets" in e.renderRoot && (o.replaceSync(r), e.renderRoot.adoptedStyleSheets = [
5
- ...e.renderRoot.adoptedStyleSheets,
6
- o
7
- ]), { ...t, element: e };
1
+ import { createMixin } from "component-register";
2
+ const withCSS = (styles) => createMixin((options) => {
3
+ const { element } = options;
4
+ const stylesheet = new CSSStyleSheet();
5
+ if ("adoptedStyleSheets" in element.renderRoot) {
6
+ stylesheet.replaceSync(styles);
7
+ element.renderRoot.adoptedStyleSheets = [
8
+ ...element.renderRoot.adoptedStyleSheets,
9
+ stylesheet
10
+ ];
11
+ }
12
+ return { ...options, element };
8
13
  });
9
14
  export {
10
- d as default
15
+ withCSS as default
11
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inradius/solid-wc-css-mixin",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "license": "MIT",
5
5
  "author": "Travis Stroud <travis.unfasten577@travisstroud.me>",
6
6
  "description": "A Solid.js CSS web component mixin.",
@@ -42,7 +42,7 @@
42
42
  "vite": "^5.4.0",
43
43
  "vite-plugin-dts": "^4.0.0",
44
44
  "vitest": "^2.1.0",
45
- "@inradius/solid-wc-utils-config": "0.0.0"
45
+ "@inradius/solid-wc-utils-config": "0.1.1"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "component-register": "^0.8.8"