simplestyle-js 4.1.1 → 4.1.3
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 +1 -1
- package/dist/cjs/createStyles.cjs +19 -10
- package/dist/cjs/createStyles.d.ts +8 -2
- package/dist/esm/createStyles.d.ts +8 -2
- package/dist/esm/createStyles.mjs +19 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ Rules support nested selectors via `&`, media queries, and `$className` back-ref
|
|
|
94
94
|
|
|
95
95
|
- `keyframes(ruleId, frames, options?)`
|
|
96
96
|
- Generates a unique animation name and accompanying `@keyframes` CSS.
|
|
97
|
-
- Returns `
|
|
97
|
+
- Returns `{ keyframe: string; stylesheet: string; }`. Respects `flush` and `insertBefore/After` options.
|
|
98
98
|
|
|
99
99
|
- `rawStyles(ruleId, rules, options?)`
|
|
100
100
|
- Writes rules without generating new class names. Keys must already be selectors (e.g., `html`, `body *`, `.app`).
|
|
@@ -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
|
|
180
|
-
const { sheetBuffer: keyframesContents } = execCreateStyles(
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
const keyframeId = (0, _generateClassName.generateClassName)(`${ruleId}_keyframes`);
|
|
185
|
+
const { sheetBuffer: keyframesContents } = execCreateStyles(keyframeId, frames, coerced, null, true);
|
|
186
|
+
const stylesheet = `@keyframes ${keyframeId}{${keyframesContents}}`;
|
|
187
|
+
if (options?.registry) {
|
|
188
|
+
options.registry.add(keyframeId, stylesheet);
|
|
189
|
+
} else if (coerced.flush) {
|
|
190
|
+
flushSheetContents(keyframeId, stylesheet);
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
keyframe: keyframeId,
|
|
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
|
+
keyframe: string;
|
|
33
|
+
stylesheet: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function makeKeyframes(registry: SimpleStyleRegistry): <T extends Record<string, Properties>>(ruleId: string, rules: T) => {
|
|
36
|
+
keyframe: 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;
|
|
@@ -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
|
+
keyframe: string;
|
|
33
|
+
stylesheet: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function makeKeyframes(registry: SimpleStyleRegistry): <T extends Record<string, Properties>>(ruleId: string, rules: T) => {
|
|
36
|
+
keyframe: 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;
|
|
@@ -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
|
|
145
|
-
const { sheetBuffer: keyframesContents } = execCreateStyles(
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
const keyframeId = generateClassName(`${ruleId}_keyframes`);
|
|
150
|
+
const { sheetBuffer: keyframesContents } = execCreateStyles(keyframeId, frames, coerced, null, true);
|
|
151
|
+
const stylesheet = `@keyframes ${keyframeId}{${keyframesContents}}`;
|
|
152
|
+
if (options?.registry) {
|
|
153
|
+
options.registry.add(keyframeId, stylesheet);
|
|
154
|
+
} else if (coerced.flush) {
|
|
155
|
+
flushSheetContents(keyframeId, stylesheet);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
keyframe: keyframeId,
|
|
159
|
+
stylesheet
|
|
160
|
+
};
|
|
152
161
|
}
|
|
153
162
|
export function makeKeyframes(registry) {
|
|
154
163
|
return function wrappedCreateKeyframes(ruleId, rules) {
|
package/package.json
CHANGED