boss-css 0.0.8 → 0.0.9

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.
@@ -45,7 +45,7 @@ const onBrowserObjectStart = (api, { input, output = {}, tag, contexts = [] }) =
45
45
  output: outputRecord,
46
46
  contexts
47
47
  });
48
- else if (!descriptor && !contexts.length && (0, _boss_css_is_css_prop.default)(tag, resolvedName)) outputRecord.style[resolvedName] = api.dictionary.toValue(value, resolvedName);
48
+ else if (!contexts.length && (0, _boss_css_is_css_prop.default)(tag, resolvedName)) outputRecord.style[resolvedName] = api.dictionary.toValue(value, resolvedName);
49
49
  else {
50
50
  const className = api.contextToClassName(resolvedName, null, contexts, false, api.selectorPrefix);
51
51
  const cssVarName = api.contextToCSSVariable(resolvedName, null, contexts, api.selectorPrefix);
@@ -43,7 +43,7 @@ const onBrowserObjectStart = (api, { input, output = {}, tag, contexts = [] }) =
43
43
  output: outputRecord,
44
44
  contexts
45
45
  });
46
- else if (!descriptor && !contexts.length && isCSSProp(tag, resolvedName)) outputRecord.style[resolvedName] = api.dictionary.toValue(value, resolvedName);
46
+ else if (!contexts.length && isCSSProp(tag, resolvedName)) outputRecord.style[resolvedName] = api.dictionary.toValue(value, resolvedName);
47
47
  else {
48
48
  const className = api.contextToClassName(resolvedName, null, contexts, false, api.selectorPrefix);
49
49
  const cssVarName = api.contextToCSSVariable(resolvedName, null, contexts, api.selectorPrefix);
@@ -61,10 +61,16 @@ const onBrowserObjectStart = (api, { input }) => {
61
61
  if (isClassnameFirst) mutableInput[prop] = path.split(".").slice(1).join(".");
62
62
  else mutableInput[prop] = `var(--${path.replace(/\./g, "-")})`;
63
63
  } else if (typeof prop === "string") {
64
- const groupName = require_propMap.getTokenGroupForProp(prop) ?? require_propMap.getTokenGroupForProp(api.camelCaseToDash?.(prop) ?? prop);
65
- if (groupName && tokenPaths.has(`${groupName}.${mutableInput[prop]}`)) {
66
- if (!isClassnameFirst) mutableInput[prop] = `var(--${groupName}-${String(mutableInput[prop]).replace("$$.token.", "").replace(/\./g, "-")})`;
67
- }
64
+ const rawValue = mutableInput[prop];
65
+ if (typeof rawValue !== "string") continue;
66
+ const dashProp = api.camelCaseToDash?.(prop) ?? prop;
67
+ const groupName = [
68
+ require_propMap.getTokenGroupForProp(prop),
69
+ require_propMap.getTokenGroupForProp(dashProp),
70
+ prop,
71
+ dashProp
72
+ ].filter(Boolean).find((group) => tokenPaths.has(`${group}.${rawValue}`));
73
+ if (groupName && !isClassnameFirst) mutableInput[prop] = `var(--${groupName}-${rawValue.replace("$$.token.", "").replace(/\./g, "-")})`;
68
74
  }
69
75
  }
70
76
  };
@@ -61,10 +61,16 @@ const onBrowserObjectStart = (api, { input }) => {
61
61
  if (isClassnameFirst) mutableInput[prop] = path.split(".").slice(1).join(".");
62
62
  else mutableInput[prop] = `var(--${path.replace(/\./g, "-")})`;
63
63
  } else if (typeof prop === "string") {
64
- const groupName = getTokenGroupForProp(prop) ?? getTokenGroupForProp(api.camelCaseToDash?.(prop) ?? prop);
65
- if (groupName && tokenPaths.has(`${groupName}.${mutableInput[prop]}`)) {
66
- if (!isClassnameFirst) mutableInput[prop] = `var(--${groupName}-${String(mutableInput[prop]).replace("$$.token.", "").replace(/\./g, "-")})`;
67
- }
64
+ const rawValue = mutableInput[prop];
65
+ if (typeof rawValue !== "string") continue;
66
+ const dashProp = api.camelCaseToDash?.(prop) ?? prop;
67
+ const groupName = [
68
+ getTokenGroupForProp(prop),
69
+ getTokenGroupForProp(dashProp),
70
+ prop,
71
+ dashProp
72
+ ].filter(Boolean).find((group) => tokenPaths.has(`${group}.${rawValue}`));
73
+ if (groupName && !isClassnameFirst) mutableInput[prop] = `var(--${groupName}-${rawValue.replace("$$.token.", "").replace(/\./g, "-")})`;
68
74
  }
69
75
  }
70
76
  };
@@ -111,10 +111,24 @@ const getTokenPath = (api, prop, value) => {
111
111
  source: "group"
112
112
  };
113
113
  if (typeof value !== "string") return null;
114
- const { byProp } = getTokenState(api);
114
+ const { byProp, groups } = getTokenState(api);
115
115
  const dashProp = api?.camelCaseToDash ? api.camelCaseToDash(prop) : prop;
116
- const groupName = require_propMap.getTokenGroupForProp(prop) ?? require_propMap.getTokenGroupForProp(dashProp) ?? prop;
117
- const values = byProp.get(prop) ?? byProp.get(dashProp);
116
+ const groupCandidates = [
117
+ require_propMap.getTokenGroupForProp(prop),
118
+ require_propMap.getTokenGroupForProp(dashProp),
119
+ prop,
120
+ dashProp
121
+ ].filter(Boolean);
122
+ let groupName = groupCandidates[0] ?? prop;
123
+ let values = byProp.get(prop) ?? byProp.get(dashProp);
124
+ if (!values) for (const candidate of groupCandidates) {
125
+ const groupValues = groups?.[candidate];
126
+ if (groupValues) {
127
+ groupName = candidate;
128
+ values = groupValues;
129
+ break;
130
+ }
131
+ }
118
132
  if (!values) return null;
119
133
  if (typeof value === "string") {
120
134
  const tokenAlpha = parseTokenAlphaValue(value);
@@ -111,10 +111,24 @@ const getTokenPath = (api, prop, value) => {
111
111
  source: "group"
112
112
  };
113
113
  if (typeof value !== "string") return null;
114
- const { byProp } = getTokenState(api);
114
+ const { byProp, groups } = getTokenState(api);
115
115
  const dashProp = api?.camelCaseToDash ? api.camelCaseToDash(prop) : prop;
116
- const groupName = getTokenGroupForProp(prop) ?? getTokenGroupForProp(dashProp) ?? prop;
117
- const values = byProp.get(prop) ?? byProp.get(dashProp);
116
+ const groupCandidates = [
117
+ getTokenGroupForProp(prop),
118
+ getTokenGroupForProp(dashProp),
119
+ prop,
120
+ dashProp
121
+ ].filter(Boolean);
122
+ let groupName = groupCandidates[0] ?? prop;
123
+ let values = byProp.get(prop) ?? byProp.get(dashProp);
124
+ if (!values) for (const candidate of groupCandidates) {
125
+ const groupValues = groups?.[candidate];
126
+ if (groupValues) {
127
+ groupName = candidate;
128
+ values = groupValues;
129
+ break;
130
+ }
131
+ }
118
132
  if (!values) return null;
119
133
  if (typeof value === "string") {
120
134
  const tokenAlpha = parseTokenAlphaValue(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boss-css",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "bin": {
6
6
  "boss": "./dist/cli/index.cjs",