css-engine-test-pb 0.0.8 → 0.1.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/dist/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export declare const shorthands: {
5
5
  export { makeStyles } from './makeStyles';
6
6
  export { makeResetStyles } from './makeResetStyles';
7
7
  export { mergeClasses } from './mergeClasses';
8
+ export { makeStaticStyles } from './makeStaticStyles';
8
9
  export type { StyleRule, CSSProperties, GeneratedClasses, StyleSlots } from './types';
package/dist/index.js CHANGED
@@ -5,3 +5,4 @@ export const shorthands = {
5
5
  export { makeStyles } from './makeStyles';
6
6
  export { makeResetStyles } from './makeResetStyles';
7
7
  export { mergeClasses } from './mergeClasses';
8
+ export { makeStaticStyles } from './makeStaticStyles';
@@ -0,0 +1,7 @@
1
+ interface StaticStyles {
2
+ [selector: string]: {
3
+ [property: string]: string | number;
4
+ };
5
+ }
6
+ export declare function makeStaticStyles(styles: StaticStyles | StaticStyles[]): () => void;
7
+ export {};
@@ -0,0 +1,25 @@
1
+ import { getGlobalEngine } from './engine';
2
+ import { StyleBucket } from './types';
3
+ export function makeStaticStyles(styles) {
4
+ const engine = getGlobalEngine();
5
+ const stylesArray = Array.isArray(styles) ? styles : [styles];
6
+ let inserted = false;
7
+ return function useStaticStyles() {
8
+ if (inserted) {
9
+ return;
10
+ }
11
+ stylesArray.forEach(styleBlock => {
12
+ Object.entries(styleBlock).forEach(([selector, properties]) => {
13
+ const cssProperties = Object.entries(properties)
14
+ .map(([prop, value]) => {
15
+ const kebabProp = prop.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);
16
+ return `${kebabProp}: ${value};`;
17
+ })
18
+ .join(' ');
19
+ const cssRule = `${selector} { ${cssProperties} }`;
20
+ engine['insertion'].insertRule(cssRule, StyleBucket.RESET);
21
+ });
22
+ });
23
+ inserted = true;
24
+ };
25
+ }
package/dist/types.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface CSSProperties {
12
12
  minHeight?: CSSValue;
13
13
  maxWidth?: CSSValue;
14
14
  maxHeight?: CSSValue;
15
+ boxSizing?: CSSValue;
15
16
  flex?: CSSValue;
16
17
  flexDirection?: CSSValue;
17
18
  flexWrap?: CSSValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-engine-test-pb",
3
- "version": "0.0.8",
3
+ "version": "0.1.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",