@plumeria/core 1.0.3 → 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
@@ -24,7 +24,7 @@ function create(object) {
24
24
  const sheet = sheetArray[i];
25
25
  const hash = hashArray[i];
26
26
  if (sheet.includes("@media") || sheet.includes("@container")) {
27
- querySheetParts.push(sheet);
27
+ querySheetParts.push(sheet.replace(`.${hash}`, `.${hash}:not(#\\#)`));
28
28
  queryHashParts.push(hash);
29
29
  } else {
30
30
  baseSheetParts.push(sheet);
@@ -43,16 +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);
46
+ const nonFlatBase = {};
47
+ const nonFlatQuery = {};
50
48
  Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
51
- Object.keys(nestedObj).forEach((prop) => {
52
- records.push({
53
- key: atRule + prop,
54
- hash: nonFlatHash,
55
- sheet: styleSheet
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
+ });
56
66
  });
57
67
  });
58
68
  });
@@ -141,7 +151,7 @@ const viewTransition = (object) => {
141
151
  return ident;
142
152
  };
143
153
 
144
- const defineTokens = (object) => {
154
+ const createTheme = (object) => {
145
155
  const styles = {};
146
156
  const result = {};
147
157
  Object.entries(object).forEach(([key, value]) => {
@@ -163,8 +173,8 @@ const defineTokens = (object) => {
163
173
  return result;
164
174
  };
165
175
 
166
- const defineConsts = (constants) => {
167
- return constants;
176
+ const createStatic = (object) => {
177
+ return object;
168
178
  };
169
179
 
170
180
  const x = (className, varSet) => ({
@@ -186,11 +196,11 @@ var StyleSheet = class {
186
196
  static viewTransition(object) {
187
197
  return viewTransition(object);
188
198
  }
189
- static defineConsts(object) {
190
- return defineConsts(object);
199
+ static createTheme(object) {
200
+ return createTheme(object);
191
201
  }
192
- static defineTokens(object) {
193
- return defineTokens(object);
202
+ static createStatic(object) {
203
+ return createStatic(object);
194
204
  }
195
205
  };
196
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) {
@@ -24,7 +24,7 @@ function create(object) {
24
24
  const sheet = sheetArray[i];
25
25
  const hash = hashArray[i];
26
26
  if (sheet.includes("@media") || sheet.includes("@container")) {
27
- querySheetParts.push(sheet);
27
+ querySheetParts.push(sheet.replace(`.${hash}`, `.${hash}:not(#\\#)`));
28
28
  queryHashParts.push(hash);
29
29
  } else {
30
30
  baseSheetParts.push(sheet);
@@ -43,16 +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);
46
+ const nonFlatBase = {};
47
+ const nonFlatQuery = {};
50
48
  Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
51
- Object.keys(nestedObj).forEach((prop) => {
52
- records.push({
53
- key: atRule + prop,
54
- hash: nonFlatHash,
55
- sheet: styleSheet
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
+ });
56
66
  });
57
67
  });
58
68
  });
@@ -141,7 +151,7 @@ const viewTransition = (object) => {
141
151
  return ident;
142
152
  };
143
153
 
144
- const defineTokens = (object) => {
154
+ const createTheme = (object) => {
145
155
  const styles = {};
146
156
  const result = {};
147
157
  Object.entries(object).forEach(([key, value]) => {
@@ -163,8 +173,8 @@ const defineTokens = (object) => {
163
173
  return result;
164
174
  };
165
175
 
166
- const defineConsts = (constants) => {
167
- return constants;
176
+ const createStatic = (object) => {
177
+ return object;
168
178
  };
169
179
 
170
180
  const x = (className, varSet) => ({
@@ -186,11 +196,11 @@ var StyleSheet = class {
186
196
  static viewTransition(object) {
187
197
  return viewTransition(object);
188
198
  }
189
- static defineConsts(object) {
190
- return defineConsts(object);
199
+ static createTheme(object) {
200
+ return createTheme(object);
191
201
  }
192
- static defineTokens(object) {
193
- return defineTokens(object);
202
+ static createStatic(object) {
203
+ return createStatic(object);
194
204
  }
195
205
  };
196
206
  const css = StyleSheet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/core",
3
- "version": "1.0.3",
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",