@wix/site-service-provide-css 1.0.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 +3 -0
- package/cjs/build/definition/index.d.ts +11 -0
- package/cjs/build/definition/index.js +6 -0
- package/cjs/build/definition/index.js.map +1 -0
- package/cjs/build/implementations/index.d.ts +1 -0
- package/cjs/build/implementations/index.js +6 -0
- package/cjs/build/implementations/index.js.map +1 -0
- package/cjs/build/implementations/provideCssService.d.ts +6 -0
- package/cjs/build/implementations/provideCssService.js +20 -0
- package/cjs/build/implementations/provideCssService.js.map +1 -0
- package/cjs/build/index.d.ts +2 -0
- package/cjs/build/index.js +19 -0
- package/cjs/build/index.js.map +1 -0
- package/cjs/build/service.d.ts +7 -0
- package/cjs/build/service.js +8 -0
- package/cjs/build/service.js.map +1 -0
- package/cjs/build/types/index.d.ts +1 -0
- package/cjs/build/types/index.js +3 -0
- package/cjs/build/types/index.js.map +1 -0
- package/cjs/package.json +3 -0
- package/definition/package.json +3 -0
- package/dist/definition/index.d.ts +11 -0
- package/dist/definition/index.js +3 -0
- package/dist/definition/index.js.map +1 -0
- package/dist/implementations/index.d.ts +1 -0
- package/dist/implementations/index.js +2 -0
- package/dist/implementations/index.js.map +1 -0
- package/dist/implementations/provideCssService.d.ts +6 -0
- package/dist/implementations/provideCssService.js +17 -0
- package/dist/implementations/provideCssService.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/service.d.ts +7 -0
- package/dist/service.js +5 -0
- package/dist/service.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/implementations/package.json +3 -0
- package/package.json +87 -0
- package/src/definition/index.ts +14 -0
- package/src/implementations/index.ts +1 -0
- package/src/implementations/provideCssService.ts +26 -0
- package/src/index.ts +2 -0
- package/src/service.ts +5 -0
- package/src/types/index.ts +1 -0
- package/types/package.json +3 -0
package/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# @wix/site-service-provide-css
|
|
2
|
+
|
|
3
|
+
> ⚠️ **No API stability guarantee.** This package is published to support Wix products and is provided as-is. Its API may change or be removed at any time without notice, and it does not follow semver compatibility guarantees. Use at your own risk.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StaticServiceDefinition } from '@wix/static-service';
|
|
2
|
+
export type IProvideCssServiceConfig = Record<string, never>;
|
|
3
|
+
export interface IProvideCssService {
|
|
4
|
+
addStyle: (newCss: string) => void;
|
|
5
|
+
}
|
|
6
|
+
export type IProvideCssDefinition = StaticServiceDefinition<IProvideCssService, IProvideCssServiceConfig>;
|
|
7
|
+
export declare const ProvideCssDefinition: string & {
|
|
8
|
+
__api: IProvideCssService;
|
|
9
|
+
__config: IProvideCssServiceConfig;
|
|
10
|
+
isServiceDefinition?: boolean;
|
|
11
|
+
} & IProvideCssService;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProvideCssDefinition = void 0;
|
|
4
|
+
const static_service_1 = require("@wix/static-service");
|
|
5
|
+
exports.ProvideCssDefinition = (0, static_service_1.defineStaticService)('@wix/site-service-provide-css');
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyD;AAW5C,QAAA,oBAAoB,GAAG,IAAA,oCAAmB,EACnD,+BAA+B,CAClC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProvideCssService } from './provideCssService';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProvideCssService = void 0;
|
|
4
|
+
var provideCssService_1 = require("./provideCssService");
|
|
5
|
+
Object.defineProperty(exports, "ProvideCssService", { enumerable: true, get: function () { return provideCssService_1.ProvideCssService; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/implementations/index.ts"],"names":[],"mappings":";;;AAAA,yDAAuD;AAA9C,sHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IProvideCssService, IProvideCssServiceConfig } from '../definition';
|
|
2
|
+
export declare const ProvideCssService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
3
|
+
__api: IProvideCssService;
|
|
4
|
+
__config: IProvideCssServiceConfig;
|
|
5
|
+
isServiceDefinition?: boolean;
|
|
6
|
+
} & IProvideCssService, IProvideCssServiceConfig>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProvideCssService = void 0;
|
|
4
|
+
const static_service_1 = require("@wix/static-service");
|
|
5
|
+
const provide_component_1 = require("@wix/services-manager-react/core-services/provide-component");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const definition_1 = require("../definition");
|
|
8
|
+
exports.ProvideCssService = (0, static_service_1.implementStaticService)(definition_1.ProvideCssDefinition, ({ getService }) => {
|
|
9
|
+
const provideComponentService = getService(provide_component_1.ProvideComponentServiceDefinition);
|
|
10
|
+
const addStyle = (newCss) => {
|
|
11
|
+
if (!newCss)
|
|
12
|
+
return;
|
|
13
|
+
const CSSProvider = () => (0, react_1.createElement)('style', null, newCss.trim());
|
|
14
|
+
provideComponentService.addBottomComponent(CSSProvider);
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
addStyle,
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=provideCssService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provideCssService.js","sourceRoot":"","sources":["../../../src/implementations/provideCssService.ts"],"names":[],"mappings":";;;AAAA,wDAA4D;AAE5D,mGAA+G;AAE/G,iCAAqC;AAErC,8CAAoD;AAEvC,QAAA,iBAAiB,GAAG,IAAA,uCAAsB,EACnD,iCAAoB,EACpB,CAAC,EAAE,UAAU,EAAsD,EAAsB,EAAE;IACvF,MAAM,uBAAuB,GAAG,UAAU,CAAC,qDAAiC,CAAC,CAAA;IAE7E,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,EAAE;QAChC,IAAI,CAAC,MAAM;YAAE,OAAM;QAEnB,MAAM,WAAW,GAAyC,GAAG,EAAE,CAAC,IAAA,qBAAa,EAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QAE3G,uBAAuB,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAA;IAC3D,CAAC,CAAA;IAED,OAAO;QACH,QAAQ;KACX,CAAA;AACL,CAAC,CACJ,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./definition"), exports);
|
|
18
|
+
__exportStar(require("./implementations"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,oDAAiC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProvideCssService } from './implementations/provideCssService';
|
|
2
|
+
export declare const definition: string & {
|
|
3
|
+
__api: import("./definition").IProvideCssService;
|
|
4
|
+
__config: import("./definition").IProvideCssServiceConfig;
|
|
5
|
+
isServiceDefinition?: boolean;
|
|
6
|
+
} & import("./definition").IProvideCssService;
|
|
7
|
+
export default ProvideCssService;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.definition = void 0;
|
|
4
|
+
const definition_1 = require("./definition");
|
|
5
|
+
const provideCssService_1 = require("./implementations/provideCssService");
|
|
6
|
+
exports.definition = definition_1.ProvideCssDefinition;
|
|
7
|
+
exports.default = provideCssService_1.ProvideCssService;
|
|
8
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":";;;AAAA,6CAAmD;AACnD,2EAAuE;AAE1D,QAAA,UAAU,GAAG,iCAAoB,CAAA;AAC9C,kBAAe,qCAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { IProvideCssService, IProvideCssServiceConfig, IProvideCssDefinition } from '../definition';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":""}
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StaticServiceDefinition } from '@wix/static-service';
|
|
2
|
+
export type IProvideCssServiceConfig = Record<string, never>;
|
|
3
|
+
export interface IProvideCssService {
|
|
4
|
+
addStyle: (newCss: string) => void;
|
|
5
|
+
}
|
|
6
|
+
export type IProvideCssDefinition = StaticServiceDefinition<IProvideCssService, IProvideCssServiceConfig>;
|
|
7
|
+
export declare const ProvideCssDefinition: string & {
|
|
8
|
+
__api: IProvideCssService;
|
|
9
|
+
__config: IProvideCssServiceConfig;
|
|
10
|
+
isServiceDefinition?: boolean;
|
|
11
|
+
} & IProvideCssService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAWzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CACnD,+BAA+B,CAClC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProvideCssService } from './provideCssService';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/implementations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IProvideCssService, IProvideCssServiceConfig } from '../definition';
|
|
2
|
+
export declare const ProvideCssService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
3
|
+
__api: IProvideCssService;
|
|
4
|
+
__config: IProvideCssServiceConfig;
|
|
5
|
+
isServiceDefinition?: boolean;
|
|
6
|
+
} & IProvideCssService, IProvideCssServiceConfig>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { implementStaticService } from '@wix/static-service';
|
|
2
|
+
import { ProvideComponentServiceDefinition } from '@wix/services-manager-react/core-services/provide-component';
|
|
3
|
+
import { createElement } from 'react';
|
|
4
|
+
import { ProvideCssDefinition } from '../definition';
|
|
5
|
+
export const ProvideCssService = implementStaticService(ProvideCssDefinition, ({ getService }) => {
|
|
6
|
+
const provideComponentService = getService(ProvideComponentServiceDefinition);
|
|
7
|
+
const addStyle = (newCss) => {
|
|
8
|
+
if (!newCss)
|
|
9
|
+
return;
|
|
10
|
+
const CSSProvider = () => createElement('style', null, newCss.trim());
|
|
11
|
+
provideComponentService.addBottomComponent(CSSProvider);
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
addStyle,
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=provideCssService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provideCssService.js","sourceRoot":"","sources":["../../src/implementations/provideCssService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,EAAE,iCAAiC,EAAE,MAAM,6DAA6D,CAAA;AAE/G,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAEpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,sBAAsB,CACnD,oBAAoB,EACpB,CAAC,EAAE,UAAU,EAAsD,EAAsB,EAAE;IACvF,MAAM,uBAAuB,GAAG,UAAU,CAAC,iCAAiC,CAAC,CAAA;IAE7E,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,EAAE;QAChC,IAAI,CAAC,MAAM;YAAE,OAAM;QAEnB,MAAM,WAAW,GAAyC,GAAG,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QAE3G,uBAAuB,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAA;IAC3D,CAAC,CAAA;IAED,OAAO;QACH,QAAQ;KACX,CAAA;AACL,CAAC,CACJ,CAAA"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProvideCssService } from './implementations/provideCssService';
|
|
2
|
+
export declare const definition: string & {
|
|
3
|
+
__api: import("./definition").IProvideCssService;
|
|
4
|
+
__config: import("./definition").IProvideCssServiceConfig;
|
|
5
|
+
isServiceDefinition?: boolean;
|
|
6
|
+
} & import("./definition").IProvideCssService;
|
|
7
|
+
export default ProvideCssService;
|
package/dist/service.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAEvE,MAAM,CAAC,MAAM,UAAU,GAAG,oBAAoB,CAAA;AAC9C,eAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { IProvideCssService, IProvideCssServiceConfig, IProvideCssDefinition } from '../definition';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wix/site-service-provide-css",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"main": "cjs/build/index.js",
|
|
5
|
+
"module": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src",
|
|
11
|
+
"cjs",
|
|
12
|
+
"definition",
|
|
13
|
+
"implementations",
|
|
14
|
+
"types",
|
|
15
|
+
"!**/*.tsbuildinfo",
|
|
16
|
+
"!doc.md"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"require": "./cjs/build/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./definition": {
|
|
25
|
+
"types": "./dist/definition/index.d.ts",
|
|
26
|
+
"import": "./dist/definition/index.js",
|
|
27
|
+
"require": "./cjs/build/definition/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./implementations": {
|
|
30
|
+
"types": "./dist/implementations/index.d.ts",
|
|
31
|
+
"import": "./dist/implementations/index.js",
|
|
32
|
+
"require": "./cjs/build/implementations/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./types": {
|
|
35
|
+
"types": "./dist/types/index.d.ts",
|
|
36
|
+
"import": "./dist/types/index.js",
|
|
37
|
+
"require": "./cjs/build/types/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./service": {
|
|
40
|
+
"types": "./dist/service.d.ts",
|
|
41
|
+
"import": "./dist/service.js",
|
|
42
|
+
"require": "./cjs/build/service.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@wix/services-manager": "^0.2.20",
|
|
47
|
+
"@wix/services-manager-react": "^0.1.26",
|
|
48
|
+
"@wix/static-service": "1.0.19",
|
|
49
|
+
"react": "^18.3.1",
|
|
50
|
+
"react-dom": "^18.0.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
54
|
+
"@testing-library/react": "^16.2.0",
|
|
55
|
+
"typescript": "^5.3.3",
|
|
56
|
+
"vitest": "4.1.0"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsc -b . --force && tsc --project tsconfig.cjs.json",
|
|
60
|
+
"lint": "yarn run -T lint:package $npm_package_name",
|
|
61
|
+
"test": "vitest --run && yarn test-type-check",
|
|
62
|
+
"test-type-check": "echo 'validating typescript in test files' && tsc --project tsconfig.test.json && echo 'Finished validating typescript in test files successfully'"
|
|
63
|
+
},
|
|
64
|
+
"publishUnscoped": false,
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"registry": "https://registry.npmjs.org/",
|
|
67
|
+
"access": "public"
|
|
68
|
+
},
|
|
69
|
+
"sideEffects": false,
|
|
70
|
+
"wix": {
|
|
71
|
+
"artifact": {
|
|
72
|
+
"groupId": "com.wixpress.npm",
|
|
73
|
+
"artifactId": "site-service-provide-css",
|
|
74
|
+
"targets": {
|
|
75
|
+
"static": false,
|
|
76
|
+
"docker": false
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"validations": {
|
|
80
|
+
"postBuild": [
|
|
81
|
+
"test",
|
|
82
|
+
"lint"
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"falconPackageHash": "0d392c53411db7a79a35ac7c261970d664b6ab9ec2c1cb5738455845"
|
|
87
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineStaticService } from '@wix/static-service'
|
|
2
|
+
import type { StaticServiceDefinition } from '@wix/static-service'
|
|
3
|
+
|
|
4
|
+
export type IProvideCssServiceConfig = Record<string, never>
|
|
5
|
+
|
|
6
|
+
export interface IProvideCssService {
|
|
7
|
+
addStyle: (newCss: string) => void
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type IProvideCssDefinition = StaticServiceDefinition<IProvideCssService, IProvideCssServiceConfig>
|
|
11
|
+
|
|
12
|
+
export const ProvideCssDefinition = defineStaticService<IProvideCssService, IProvideCssServiceConfig>(
|
|
13
|
+
'@wix/site-service-provide-css'
|
|
14
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ProvideCssService } from './provideCssService'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { implementStaticService } from '@wix/static-service'
|
|
2
|
+
import type { StaticServiceFactoryOpts } from '@wix/static-service'
|
|
3
|
+
import { ProvideComponentServiceDefinition } from '@wix/services-manager-react/core-services/provide-component'
|
|
4
|
+
import type { FunctionComponent, PropsWithChildren } from 'react'
|
|
5
|
+
import { createElement } from 'react'
|
|
6
|
+
import type { IProvideCssService, IProvideCssServiceConfig } from '../definition'
|
|
7
|
+
import { ProvideCssDefinition } from '../definition'
|
|
8
|
+
|
|
9
|
+
export const ProvideCssService = implementStaticService(
|
|
10
|
+
ProvideCssDefinition,
|
|
11
|
+
({ getService }: StaticServiceFactoryOpts<IProvideCssServiceConfig>): IProvideCssService => {
|
|
12
|
+
const provideComponentService = getService(ProvideComponentServiceDefinition)
|
|
13
|
+
|
|
14
|
+
const addStyle = (newCss: string) => {
|
|
15
|
+
if (!newCss) return
|
|
16
|
+
|
|
17
|
+
const CSSProvider: FunctionComponent<PropsWithChildren> = () => createElement('style', null, newCss.trim())
|
|
18
|
+
|
|
19
|
+
provideComponentService.addBottomComponent(CSSProvider)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
addStyle,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
)
|
package/src/index.ts
ADDED
package/src/service.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { IProvideCssService, IProvideCssServiceConfig, IProvideCssDefinition } from '../definition'
|