simplestyle-js 4.1.0 → 4.1.2
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/cjs/createStyles.cjs +19 -10
- package/dist/cjs/createStyles.d.ts +8 -2
- package/dist/cjs/generateClassName.cjs +1 -1
- package/dist/cjs/index.cjs +3 -3
- package/dist/cjs/react/index.cjs +1 -1
- package/dist/cjs/react/useCreateStyles.cjs +2 -2
- package/dist/cjs/util/index.cjs +1 -1
- package/dist/esm/createStyles.d.ts +8 -2
- package/dist/esm/createStyles.mjs +19 -10
- package/dist/esm/generateClassName.mjs +1 -1
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/react/index.mjs +1 -1
- package/dist/esm/react/useCreateStyles.mjs +2 -2
- package/dist/esm/util/index.mjs +1 -1
- package/package.json +112 -2
|
@@ -29,8 +29,8 @@ _export(exports, {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
const _deepmerge = /*#__PURE__*/ _interop_require_default(require("deepmerge"));
|
|
32
|
-
const _generateClassName = require("./generateClassName.
|
|
33
|
-
const _plugins = require("./plugins.
|
|
32
|
+
const _generateClassName = require("./generateClassName.cjs");
|
|
33
|
+
const _plugins = require("./plugins.cjs");
|
|
34
34
|
function _interop_require_default(obj) {
|
|
35
35
|
return obj && obj.__esModule ? obj : {
|
|
36
36
|
default: obj
|
|
@@ -161,10 +161,15 @@ function coerceCreateStylesOptions(options) {
|
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
function rawStyles(ruleId, rules, options) {
|
|
164
|
+
const rawStylesId = `${ruleId}_raw`;
|
|
164
165
|
const coerced = coerceCreateStylesOptions(options);
|
|
165
|
-
const { sheetBuffer: sheetContents, mediaQueriesBuffer: mediaQueriesContents } = execCreateStyles(
|
|
166
|
+
const { sheetBuffer: sheetContents, mediaQueriesBuffer: mediaQueriesContents } = execCreateStyles(rawStylesId, rules, coerced, null, true);
|
|
166
167
|
const mergedContents = `${sheetContents}${mediaQueriesContents}`;
|
|
167
|
-
if (
|
|
168
|
+
if (options?.registry) {
|
|
169
|
+
options.registry.add(rawStylesId, mergedContents);
|
|
170
|
+
} else if (coerced.flush) {
|
|
171
|
+
flushSheetContents(rawStylesId, mergedContents, options);
|
|
172
|
+
}
|
|
168
173
|
return mergedContents;
|
|
169
174
|
}
|
|
170
175
|
function makeRawStyles(registry) {
|
|
@@ -176,14 +181,18 @@ function makeRawStyles(registry) {
|
|
|
176
181
|
}
|
|
177
182
|
function keyframes(ruleId, frames, options) {
|
|
178
183
|
const coerced = coerceCreateStylesOptions(options);
|
|
179
|
-
const keyframeName = (0, _generateClassName.generateClassName)(`${ruleId}
|
|
184
|
+
const keyframeName = (0, _generateClassName.generateClassName)(`${ruleId}_keyframes`);
|
|
180
185
|
const { sheetBuffer: keyframesContents } = execCreateStyles(ruleId, frames, coerced, null, true);
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
183
|
-
|
|
186
|
+
const stylesheet = `@keyframes ${keyframeName}{${keyframesContents}}`;
|
|
187
|
+
if (options?.registry) {
|
|
188
|
+
options.registry.add(keyframeName, keyframesContents);
|
|
189
|
+
} else if (coerced.flush) {
|
|
190
|
+
flushSheetContents(ruleId, stylesheet);
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
184
193
|
keyframeName,
|
|
185
|
-
|
|
186
|
-
|
|
194
|
+
stylesheet
|
|
195
|
+
};
|
|
187
196
|
}
|
|
188
197
|
function makeKeyframes(registry) {
|
|
189
198
|
return function wrappedCreateKeyframes(ruleId, rules) {
|
|
@@ -28,8 +28,14 @@ export type CreateStylesOptions = Partial<{
|
|
|
28
28
|
}>;
|
|
29
29
|
export declare function rawStyles<T extends SimpleStyleRules>(ruleId: string, rules: T, options?: Partial<CreateStylesOptions>): string;
|
|
30
30
|
export declare function makeRawStyles(registry: SimpleStyleRegistry): <T extends SimpleStyleRules>(ruleId: string, rules: T) => string;
|
|
31
|
-
export declare function keyframes<T extends Record<string, Properties>>(ruleId: string, frames: T, options?: CreateStylesOptions):
|
|
32
|
-
|
|
31
|
+
export declare function keyframes<T extends Record<string, Properties>>(ruleId: string, frames: T, options?: CreateStylesOptions): {
|
|
32
|
+
keyframeName: string;
|
|
33
|
+
stylesheet: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function makeKeyframes(registry: SimpleStyleRegistry): <T extends Record<string, Properties>>(ruleId: string, rules: T) => {
|
|
36
|
+
keyframeName: string;
|
|
37
|
+
stylesheet: string;
|
|
38
|
+
};
|
|
33
39
|
export declare function makeCreateStyles(registry: SimpleStyleRegistry): <T extends SimpleStyleRules, K extends keyof T, O extends Record<K, string>>(ruleId: string, rules: T) => {
|
|
34
40
|
classes: O;
|
|
35
41
|
stylesheet: string;
|
|
@@ -19,7 +19,7 @@ _export(exports, {
|
|
|
19
19
|
return setSeed;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
const _numToAlpha = /*#__PURE__*/ _interop_require_default(require("./numToAlpha.
|
|
22
|
+
const _numToAlpha = /*#__PURE__*/ _interop_require_default(require("./numToAlpha.cjs"));
|
|
23
23
|
function _interop_require_default(obj) {
|
|
24
24
|
return obj && obj.__esModule ? obj : {
|
|
25
25
|
default: obj
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -34,9 +34,9 @@ _export(exports, {
|
|
|
34
34
|
return _generateClassName.setSeed;
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
|
-
const _createStyles = /*#__PURE__*/ _interop_require_wildcard(require("./createStyles.
|
|
38
|
-
const _generateClassName = require("./generateClassName.
|
|
39
|
-
const _plugins = require("./plugins.
|
|
37
|
+
const _createStyles = /*#__PURE__*/ _interop_require_wildcard(require("./createStyles.cjs"));
|
|
38
|
+
const _generateClassName = require("./generateClassName.cjs");
|
|
39
|
+
const _plugins = require("./plugins.cjs");
|
|
40
40
|
function _getRequireWildcardCache(nodeInterop) {
|
|
41
41
|
if (typeof WeakMap !== "function") return null;
|
|
42
42
|
var cacheBabelInterop = new WeakMap();
|
package/dist/cjs/react/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
_export_star(require("./useCreateStyles.
|
|
5
|
+
_export_star(require("./useCreateStyles.cjs"), exports);
|
|
6
6
|
function _export_star(from, to) {
|
|
7
7
|
Object.keys(from).forEach(function(k) {
|
|
8
8
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "useCreateStyles", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _react = require("react");
|
|
12
|
-
const _createStyles = /*#__PURE__*/ _interop_require_default(require("../createStyles.
|
|
13
|
-
const _index = require("../util/index.
|
|
12
|
+
const _createStyles = /*#__PURE__*/ _interop_require_default(require("../createStyles.cjs"));
|
|
13
|
+
const _index = require("../util/index.cjs");
|
|
14
14
|
function _interop_require_default(obj) {
|
|
15
15
|
return obj && obj.__esModule ? obj : {
|
|
16
16
|
default: obj
|
package/dist/cjs/util/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
_export_star(require("./deepEqual.
|
|
5
|
+
_export_star(require("./deepEqual.cjs"), exports);
|
|
6
6
|
function _export_star(from, to) {
|
|
7
7
|
Object.keys(from).forEach(function(k) {
|
|
8
8
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -28,8 +28,14 @@ export type CreateStylesOptions = Partial<{
|
|
|
28
28
|
}>;
|
|
29
29
|
export declare function rawStyles<T extends SimpleStyleRules>(ruleId: string, rules: T, options?: Partial<CreateStylesOptions>): string;
|
|
30
30
|
export declare function makeRawStyles(registry: SimpleStyleRegistry): <T extends SimpleStyleRules>(ruleId: string, rules: T) => string;
|
|
31
|
-
export declare function keyframes<T extends Record<string, Properties>>(ruleId: string, frames: T, options?: CreateStylesOptions):
|
|
32
|
-
|
|
31
|
+
export declare function keyframes<T extends Record<string, Properties>>(ruleId: string, frames: T, options?: CreateStylesOptions): {
|
|
32
|
+
keyframeName: string;
|
|
33
|
+
stylesheet: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function makeKeyframes(registry: SimpleStyleRegistry): <T extends Record<string, Properties>>(ruleId: string, rules: T) => {
|
|
36
|
+
keyframeName: string;
|
|
37
|
+
stylesheet: string;
|
|
38
|
+
};
|
|
33
39
|
export declare function makeCreateStyles(registry: SimpleStyleRegistry): <T extends SimpleStyleRules, K extends keyof T, O extends Record<K, string>>(ruleId: string, rules: T) => {
|
|
34
40
|
classes: O;
|
|
35
41
|
stylesheet: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-deprecated */ import merge from 'deepmerge';
|
|
2
|
-
import { generateClassName } from './generateClassName.
|
|
3
|
-
import { getPosthooks } from './plugins.
|
|
2
|
+
import { generateClassName } from './generateClassName.mjs';
|
|
3
|
+
import { getPosthooks } from './plugins.mjs';
|
|
4
4
|
function isNestedSelector(r) {
|
|
5
5
|
return /&/g.test(r);
|
|
6
6
|
}
|
|
@@ -126,10 +126,15 @@ function coerceCreateStylesOptions(options) {
|
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
export function rawStyles(ruleId, rules, options) {
|
|
129
|
+
const rawStylesId = `${ruleId}_raw`;
|
|
129
130
|
const coerced = coerceCreateStylesOptions(options);
|
|
130
|
-
const { sheetBuffer: sheetContents, mediaQueriesBuffer: mediaQueriesContents } = execCreateStyles(
|
|
131
|
+
const { sheetBuffer: sheetContents, mediaQueriesBuffer: mediaQueriesContents } = execCreateStyles(rawStylesId, rules, coerced, null, true);
|
|
131
132
|
const mergedContents = `${sheetContents}${mediaQueriesContents}`;
|
|
132
|
-
if (
|
|
133
|
+
if (options?.registry) {
|
|
134
|
+
options.registry.add(rawStylesId, mergedContents);
|
|
135
|
+
} else if (coerced.flush) {
|
|
136
|
+
flushSheetContents(rawStylesId, mergedContents, options);
|
|
137
|
+
}
|
|
133
138
|
return mergedContents;
|
|
134
139
|
}
|
|
135
140
|
export function makeRawStyles(registry) {
|
|
@@ -141,14 +146,18 @@ export function makeRawStyles(registry) {
|
|
|
141
146
|
}
|
|
142
147
|
export function keyframes(ruleId, frames, options) {
|
|
143
148
|
const coerced = coerceCreateStylesOptions(options);
|
|
144
|
-
const keyframeName = generateClassName(`${ruleId}
|
|
149
|
+
const keyframeName = generateClassName(`${ruleId}_keyframes`);
|
|
145
150
|
const { sheetBuffer: keyframesContents } = execCreateStyles(ruleId, frames, coerced, null, true);
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
148
|
-
|
|
151
|
+
const stylesheet = `@keyframes ${keyframeName}{${keyframesContents}}`;
|
|
152
|
+
if (options?.registry) {
|
|
153
|
+
options.registry.add(keyframeName, keyframesContents);
|
|
154
|
+
} else if (coerced.flush) {
|
|
155
|
+
flushSheetContents(ruleId, stylesheet);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
149
158
|
keyframeName,
|
|
150
|
-
|
|
151
|
-
|
|
159
|
+
stylesheet
|
|
160
|
+
};
|
|
152
161
|
}
|
|
153
162
|
export function makeKeyframes(registry) {
|
|
154
163
|
return function wrappedCreateKeyframes(ruleId, rules) {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as createStyles, keyframes, makeCreateStyles, makeKeyframes, makeRawStyles, rawStyles } from './createStyles.
|
|
2
|
-
export { setSeed } from './generateClassName.
|
|
3
|
-
export { registerPosthook } from './plugins.
|
|
1
|
+
export { default as createStyles, keyframes, makeCreateStyles, makeKeyframes, makeRawStyles, rawStyles } from './createStyles.mjs';
|
|
2
|
+
export { setSeed } from './generateClassName.mjs';
|
|
3
|
+
export { registerPosthook } from './plugins.mjs';
|
package/dist/esm/react/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './useCreateStyles.
|
|
1
|
+
export * from './useCreateStyles.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import createStyles from '../createStyles.
|
|
3
|
-
import { deepEqual } from '../util/index.
|
|
2
|
+
import createStyles from '../createStyles.mjs';
|
|
3
|
+
import { deepEqual } from '../util/index.mjs';
|
|
4
4
|
export function useCreateStyles(ruleId, rules, options) {
|
|
5
5
|
// cache rules to compare later
|
|
6
6
|
const [cachedRules, setCachedRules] = useState(()=>rules);
|
package/dist/esm/util/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './deepEqual.
|
|
1
|
+
export * from './deepEqual.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simplestyle-js",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"description": "An incredibly straightforward and simple CSS-in-JS solution with zero runtime dependencies, and out-of-the-box TypeScript support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -60,9 +60,119 @@
|
|
|
60
60
|
"react": ">=16.8"
|
|
61
61
|
},
|
|
62
62
|
"exports": {
|
|
63
|
+
"./createStyles": {
|
|
64
|
+
"require": {
|
|
65
|
+
"types": "./dist/cjs/createStyles.d.ts",
|
|
66
|
+
"default": "./dist/cjs/createStyles.cjs"
|
|
67
|
+
},
|
|
68
|
+
"import": {
|
|
69
|
+
"types": "./dist/esm/createStyles.d.ts",
|
|
70
|
+
"default": "./dist/esm/createStyles.mjs"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"./generateClassName": {
|
|
74
|
+
"require": {
|
|
75
|
+
"types": "./dist/cjs/generateClassName.d.ts",
|
|
76
|
+
"default": "./dist/cjs/generateClassName.cjs"
|
|
77
|
+
},
|
|
78
|
+
"import": {
|
|
79
|
+
"types": "./dist/esm/generateClassName.d.ts",
|
|
80
|
+
"default": "./dist/esm/generateClassName.mjs"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
".": {
|
|
84
|
+
"require": {
|
|
85
|
+
"types": "./dist/cjs/index.d.ts",
|
|
86
|
+
"default": "./dist/cjs/index.cjs"
|
|
87
|
+
},
|
|
88
|
+
"import": {
|
|
89
|
+
"types": "./dist/esm/index.d.ts",
|
|
90
|
+
"default": "./dist/esm/index.mjs"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"./numToAlpha": {
|
|
94
|
+
"require": {
|
|
95
|
+
"types": "./dist/cjs/numToAlpha.d.ts",
|
|
96
|
+
"default": "./dist/cjs/numToAlpha.cjs"
|
|
97
|
+
},
|
|
98
|
+
"import": {
|
|
99
|
+
"types": "./dist/esm/numToAlpha.d.ts",
|
|
100
|
+
"default": "./dist/esm/numToAlpha.mjs"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"./plugins": {
|
|
104
|
+
"require": {
|
|
105
|
+
"types": "./dist/cjs/plugins.d.ts",
|
|
106
|
+
"default": "./dist/cjs/plugins.cjs"
|
|
107
|
+
},
|
|
108
|
+
"import": {
|
|
109
|
+
"types": "./dist/esm/plugins.d.ts",
|
|
110
|
+
"default": "./dist/esm/plugins.mjs"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"./react": {
|
|
114
|
+
"require": {
|
|
115
|
+
"types": "./dist/cjs/react/index.d.ts",
|
|
116
|
+
"default": "./dist/cjs/react/index.cjs"
|
|
117
|
+
},
|
|
118
|
+
"import": {
|
|
119
|
+
"types": "./dist/esm/react/index.d.ts",
|
|
120
|
+
"default": "./dist/esm/react/index.mjs"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"./react/useCreateStyles": {
|
|
124
|
+
"require": {
|
|
125
|
+
"types": "./dist/cjs/react/useCreateStyles.d.ts",
|
|
126
|
+
"default": "./dist/cjs/react/useCreateStyles.cjs"
|
|
127
|
+
},
|
|
128
|
+
"import": {
|
|
129
|
+
"types": "./dist/esm/react/useCreateStyles.d.ts",
|
|
130
|
+
"default": "./dist/esm/react/useCreateStyles.mjs"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"./simpleStyleRegistry": {
|
|
134
|
+
"require": {
|
|
135
|
+
"types": "./dist/cjs/simpleStyleRegistry.d.ts",
|
|
136
|
+
"default": "./dist/cjs/simpleStyleRegistry.cjs"
|
|
137
|
+
},
|
|
138
|
+
"import": {
|
|
139
|
+
"types": "./dist/esm/simpleStyleRegistry.d.ts",
|
|
140
|
+
"default": "./dist/esm/simpleStyleRegistry.mjs"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"./types": {
|
|
144
|
+
"require": {
|
|
145
|
+
"types": "./dist/cjs/types.d.ts",
|
|
146
|
+
"default": "./dist/cjs/types.cjs"
|
|
147
|
+
},
|
|
148
|
+
"import": {
|
|
149
|
+
"types": "./dist/esm/types.d.ts",
|
|
150
|
+
"default": "./dist/esm/types.mjs"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"./util/deepEqual": {
|
|
154
|
+
"require": {
|
|
155
|
+
"types": "./dist/cjs/util/deepEqual.d.ts",
|
|
156
|
+
"default": "./dist/cjs/util/deepEqual.cjs"
|
|
157
|
+
},
|
|
158
|
+
"import": {
|
|
159
|
+
"types": "./dist/esm/util/deepEqual.d.ts",
|
|
160
|
+
"default": "./dist/esm/util/deepEqual.mjs"
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"./util": {
|
|
164
|
+
"require": {
|
|
165
|
+
"types": "./dist/cjs/util/index.d.ts",
|
|
166
|
+
"default": "./dist/cjs/util/index.cjs"
|
|
167
|
+
},
|
|
168
|
+
"import": {
|
|
169
|
+
"types": "./dist/esm/util/index.d.ts",
|
|
170
|
+
"default": "./dist/esm/util/index.mjs"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
63
173
|
"./package.json": "./package.json"
|
|
64
174
|
},
|
|
65
175
|
"module": "./dist/esm/index.mjs",
|
|
66
176
|
"types": "./dist/cjs/index.d.ts",
|
|
67
177
|
"main": "./dist/cjs/index.cjs"
|
|
68
|
-
}
|
|
178
|
+
}
|