@plumeria/core 1.0.4 → 2.0.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
@@ -1,11 +1,6 @@
1
- import { CSSProperties, CreateKeyframes, CreateStyle, CreateStyleType, CreateTokens, CreateValues, ReturnType, ReturnVariableType, RxVariableSet, ViewTransitionOptions } from "zss-engine";
1
+ import { CSSProperties, CreateKeyframes, CreateStyle, CreateStyleType, CreateTheme, CreateValues, ReturnType, ReturnVariableType, ReturnX, ViewTransitionOptions, XVariableSet } from "zss-engine";
2
2
 
3
- declare const x: (className: string, varSet: RxVariableSet) => {
4
- className: string;
5
- style: {
6
- [k: string]: string;
7
- };
8
- };
3
+ declare const x: (className: string, varSet: XVariableSet) => ReturnX;
9
4
 
10
5
  declare class StyleSheet {
11
6
  private constructor();
@@ -34,17 +29,17 @@ declare class StyleSheet {
34
29
  */
35
30
  static viewTransition(object: ViewTransitionOptions): string;
36
31
  /**
37
- * Returns the same object, with its type narrowed for better autocompletion.
38
- * @param object A map of keys to constant string or number values.
39
- * @see https://plumeria.dev/docs/api-reference/defineConsts
32
+ * Returns an object whose values can be used with `css.props`.
33
+ * @param object A style object containing CSS properties.
34
+ * @see https://plumeria.dev/docs/api-reference/create
40
35
  */
41
- static defineConsts<const T extends CreateValues>(object: T): T;
36
+ static createTheme<const T extends CreateTheme>(object: T): ReturnVariableType<T>;
42
37
  /**
43
- * Returns an object containing CSS variable names and the original token values.
44
- * @param object A nested object defining design tokens.
45
- * @see https://plumeria.dev/docs/api-reference/defineTokens
38
+ * Returns an object whose values can be used with `css.props`.
39
+ * @param object A style object containing CSS properties.
40
+ * @see https://plumeria.dev/docs/api-reference/create
46
41
  */
47
- static defineTokens<const T extends CreateTokens>(object: T): ReturnVariableType<T>;
42
+ static createStatic<const T extends CreateValues>(object: T): T;
48
43
  }
49
44
  declare const css: typeof StyleSheet;
50
45
 
package/dist/index.js CHANGED
@@ -43,18 +43,26 @@ function create(object) {
43
43
  });
44
44
  });
45
45
  if (Object.keys(nonFlat).length > 0) {
46
- const modNonFlat = (0, zss_engine.transformNestedSelectors)(nonFlat);
47
- const nonFlatObj = { [key]: modNonFlat };
48
- const nonFlatHash = (0, zss_engine.genBase36Hash)(nonFlatObj, 1, 7);
49
- const { styleSheet } = (0, zss_engine.transpile)(nonFlatObj, nonFlatHash);
50
- const isQuery = styleSheet.includes("@media") || styleSheet.includes("@container");
51
- const finalSheet = isQuery ? styleSheet.replace(`.${nonFlatHash}`, `.${nonFlatHash}:not(#\\#)`) : styleSheet;
46
+ const nonFlatBase = {};
47
+ const nonFlatQuery = {};
52
48
  Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
53
- Object.keys(nestedObj).forEach((prop) => {
54
- records.push({
55
- key: atRule + prop,
56
- hash: nonFlatHash,
57
- sheet: finalSheet
49
+ if (atRule.startsWith("@media") || atRule.startsWith("@container")) nonFlatQuery[atRule] = nestedObj;
50
+ else nonFlatBase[atRule] = nestedObj;
51
+ });
52
+ [nonFlatBase, nonFlatQuery].forEach((targetNonFlat) => {
53
+ if (Object.keys(targetNonFlat).length === 0) return;
54
+ const nonFlatObj = { [key]: targetNonFlat };
55
+ const nonFlatHash = (0, zss_engine.genBase36Hash)(nonFlatObj, 1, 7);
56
+ const { styleSheet } = (0, zss_engine.transpile)(nonFlatObj, nonFlatHash);
57
+ const isQuery = styleSheet.includes("@media") || styleSheet.includes("@container");
58
+ const finalSheet = isQuery ? styleSheet.replace(`.${nonFlatHash}`, `.${nonFlatHash}:not(#\\#)`) : styleSheet;
59
+ Object.entries(targetNonFlat).forEach(([atRule, nestedObj]) => {
60
+ Object.keys(nestedObj).forEach((prop) => {
61
+ records.push({
62
+ key: atRule + prop,
63
+ hash: nonFlatHash,
64
+ sheet: finalSheet
65
+ });
58
66
  });
59
67
  });
60
68
  });
@@ -143,7 +151,7 @@ const viewTransition = (object) => {
143
151
  return ident;
144
152
  };
145
153
 
146
- const defineTokens = (object) => {
154
+ const createTheme = (object) => {
147
155
  const styles = {};
148
156
  const result = {};
149
157
  Object.entries(object).forEach(([key, value]) => {
@@ -165,8 +173,8 @@ const defineTokens = (object) => {
165
173
  return result;
166
174
  };
167
175
 
168
- const defineConsts = (constants) => {
169
- return constants;
176
+ const createStatic = (object) => {
177
+ return object;
170
178
  };
171
179
 
172
180
  const x = (className, varSet) => ({
@@ -188,11 +196,11 @@ var StyleSheet = class {
188
196
  static viewTransition(object) {
189
197
  return viewTransition(object);
190
198
  }
191
- static defineConsts(object) {
192
- return defineConsts(object);
199
+ static createTheme(object) {
200
+ return createTheme(object);
193
201
  }
194
- static defineTokens(object) {
195
- return defineTokens(object);
202
+ static createStatic(object) {
203
+ return createStatic(object);
196
204
  }
197
205
  };
198
206
  const css = StyleSheet;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { globalPromise_1, globalPromise_2, initPromise_1, initPromise_2, resolvePromise_1, resolvePromise_2 } from "./css.mjs";
2
- import { camelToKebabCase, genBase36Hash, overrideLonghand, processAtomicProps, splitAtomicAndNested, transformNestedSelectors, transpile } from "zss-engine";
2
+ import { camelToKebabCase, genBase36Hash, overrideLonghand, processAtomicProps, splitAtomicAndNested, transpile } from "zss-engine";
3
3
 
4
4
  const styleAtomMap = new WeakMap();
5
5
  function create(object) {
@@ -43,18 +43,26 @@ function create(object) {
43
43
  });
44
44
  });
45
45
  if (Object.keys(nonFlat).length > 0) {
46
- const modNonFlat = transformNestedSelectors(nonFlat);
47
- const nonFlatObj = { [key]: modNonFlat };
48
- const nonFlatHash = genBase36Hash(nonFlatObj, 1, 7);
49
- const { styleSheet } = transpile(nonFlatObj, nonFlatHash);
50
- const isQuery = styleSheet.includes("@media") || styleSheet.includes("@container");
51
- const finalSheet = isQuery ? styleSheet.replace(`.${nonFlatHash}`, `.${nonFlatHash}:not(#\\#)`) : styleSheet;
46
+ const nonFlatBase = {};
47
+ const nonFlatQuery = {};
52
48
  Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
53
- Object.keys(nestedObj).forEach((prop) => {
54
- records.push({
55
- key: atRule + prop,
56
- hash: nonFlatHash,
57
- sheet: finalSheet
49
+ if (atRule.startsWith("@media") || atRule.startsWith("@container")) nonFlatQuery[atRule] = nestedObj;
50
+ else nonFlatBase[atRule] = nestedObj;
51
+ });
52
+ [nonFlatBase, nonFlatQuery].forEach((targetNonFlat) => {
53
+ if (Object.keys(targetNonFlat).length === 0) return;
54
+ const nonFlatObj = { [key]: targetNonFlat };
55
+ const nonFlatHash = genBase36Hash(nonFlatObj, 1, 7);
56
+ const { styleSheet } = transpile(nonFlatObj, nonFlatHash);
57
+ const isQuery = styleSheet.includes("@media") || styleSheet.includes("@container");
58
+ const finalSheet = isQuery ? styleSheet.replace(`.${nonFlatHash}`, `.${nonFlatHash}:not(#\\#)`) : styleSheet;
59
+ Object.entries(targetNonFlat).forEach(([atRule, nestedObj]) => {
60
+ Object.keys(nestedObj).forEach((prop) => {
61
+ records.push({
62
+ key: atRule + prop,
63
+ hash: nonFlatHash,
64
+ sheet: finalSheet
65
+ });
58
66
  });
59
67
  });
60
68
  });
@@ -143,7 +151,7 @@ const viewTransition = (object) => {
143
151
  return ident;
144
152
  };
145
153
 
146
- const defineTokens = (object) => {
154
+ const createTheme = (object) => {
147
155
  const styles = {};
148
156
  const result = {};
149
157
  Object.entries(object).forEach(([key, value]) => {
@@ -165,8 +173,8 @@ const defineTokens = (object) => {
165
173
  return result;
166
174
  };
167
175
 
168
- const defineConsts = (constants) => {
169
- return constants;
176
+ const createStatic = (object) => {
177
+ return object;
170
178
  };
171
179
 
172
180
  const x = (className, varSet) => ({
@@ -188,11 +196,11 @@ var StyleSheet = class {
188
196
  static viewTransition(object) {
189
197
  return viewTransition(object);
190
198
  }
191
- static defineConsts(object) {
192
- return defineConsts(object);
199
+ static createTheme(object) {
200
+ return createTheme(object);
193
201
  }
194
- static defineTokens(object) {
195
- return defineTokens(object);
202
+ static createStatic(object) {
203
+ return createStatic(object);
196
204
  }
197
205
  };
198
206
  const css = StyleSheet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/core",
3
- "version": "1.0.4",
3
+ "version": "2.0.0",
4
4
  "description": "The atomic on-demand CSS-in-JS.",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -45,7 +45,7 @@
45
45
  "stylesheet.css"
46
46
  ],
47
47
  "dependencies": {
48
- "zss-engine": "1.0.0"
48
+ "zss-engine": "1.1.0"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public",