ruscus 0.0.2 → 0.0.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/dist/index.mjs CHANGED
@@ -67,49 +67,13 @@ function createVariantProjector(anchor, format, name) {
67
67
  };
68
68
  }
69
69
  //#endregion
70
- //#region src/styles.ts
71
- /**
72
- * Convert a camel-cased value to kebab case
73
- */
74
- function camelToKebab(camel) {
75
- return camel.replace(/[A-Z]/g, (l) => `-${l.toLowerCase()}`);
76
- }
77
- /**
78
- * Merge multiple styles on top of a base
79
- */
80
- function mergeStyles(base, ...others) {
81
- const merged = { ...base };
82
- for (const other of others) Object.assign(merged, other);
83
- return merged;
84
- }
85
- var PropertyProjector = class {
86
- names;
87
- /**
88
- * Create a mapper of camel-cased values to CSS properties
89
- */
90
- constructor() {
91
- this.names = /* @__PURE__ */ new Map();
92
- }
93
- /**
94
- * Project a camel-cased value as a CSS property
95
- */
96
- project(camel) {
97
- let prop = this.names.get(camel);
98
- if (prop === void 0) {
99
- prop = camelToKebab(camel);
100
- this.names.set(camel, prop);
101
- }
102
- return prop;
103
- }
104
- };
105
- //#endregion
106
70
  //#region src/projection/identifiers.ts
107
71
  /**
108
72
  * Project a component's identifiers as a map of labels to values
109
73
  */
110
74
  function projectIdentifiers(component) {
111
75
  return Object.fromEntries(Object.entries(component.identifiers).map(([key, type]) => {
112
- const scoped = `${component.id}--${camelToKebab(key)}`;
76
+ const scoped = `${component.id}--${key}`;
113
77
  return [key, type === "variable" ? `--${scoped}` : scoped];
114
78
  }));
115
79
  }
@@ -260,6 +224,42 @@ function useNaming(component, scheme = "verbose") {
260
224
  return scheme === "compact" ? new CompactNaming(component) : new VerboseNaming(component);
261
225
  }
262
226
  //#endregion
227
+ //#region src/styles.ts
228
+ /**
229
+ * Convert a camel-cased value to kebab case
230
+ */
231
+ function camelToKebab(camel) {
232
+ return camel.replace(/[A-Z]/g, (l) => `-${l.toLowerCase()}`);
233
+ }
234
+ /**
235
+ * Merge multiple styles on top of a base
236
+ */
237
+ function mergeStyles(base, ...others) {
238
+ const merged = { ...base };
239
+ for (const other of others) Object.assign(merged, other);
240
+ return merged;
241
+ }
242
+ var PropertyProjector = class {
243
+ names;
244
+ /**
245
+ * Create a mapper of camel-cased values to CSS properties
246
+ */
247
+ constructor() {
248
+ this.names = /* @__PURE__ */ new Map();
249
+ }
250
+ /**
251
+ * Project a camel-cased value as a CSS property
252
+ */
253
+ project(camel) {
254
+ let prop = this.names.get(camel);
255
+ if (prop === void 0) {
256
+ prop = camelToKebab(camel);
257
+ this.names.set(camel, prop);
258
+ }
259
+ return prop;
260
+ }
261
+ };
262
+ //#endregion
263
263
  //#region src/compilation.ts
264
264
  /**
265
265
  * Generate CSS for a component's styles
@@ -344,7 +344,7 @@ var ComponentCompiler = class {
344
344
  const declarations = this.formatDeclarations(styles);
345
345
  if (declarations) inner.push(declarations);
346
346
  for (const [key, child] of nestedEntries) {
347
- const rule = this.formatFragmentRules(key.startsWith("&") ? `${parentSelector}${key.slice(1)}` : key, child);
347
+ const rule = this.formatFragmentRules(key.includes("&") ? this.expandSelectorAnchor(parentSelector, key) : key, child);
348
348
  if (rule) inner.push(rule);
349
349
  }
350
350
  if (!inner.length) return null;
@@ -367,10 +367,16 @@ var ComponentCompiler = class {
367
367
  return `${selector} {\n${inner.map((rule) => rule.split("\n").map((line) => `${indent}${line}`).join("\n")).join("\n\n")}\n}`;
368
368
  }
369
369
  /**
370
+ * Replace every & in a nested key with the anchor selector
371
+ */
372
+ expandSelectorAnchor(anchor, key) {
373
+ return key.replaceAll("&", anchor);
374
+ }
375
+ /**
370
376
  * Build a selector for a nested rule key
371
377
  */
372
378
  buildNestedSelector(anchor, key) {
373
- if (key.startsWith("&")) return `${anchor}${key.slice(1)}`;
379
+ if (key.includes("&")) return this.expandSelectorAnchor(anchor, key);
374
380
  else if (key === anchor) return anchor;
375
381
  else return `${anchor} ${key}`;
376
382
  }
package/dist/vite.mjs CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ruscus",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "A TypeScript library for organizing and defining component styles",
5
5
  "keywords": [
6
6
  "css",