boss-css 0.0.16 → 0.0.18

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.
@@ -41,13 +41,18 @@ const onBrowserObjectStart = (api, { input, tag = "div", contexts = [], output =
41
41
  delete input[prop];
42
42
  continue;
43
43
  }
44
- if (ignoredProps.has(prop) || require_isDOMProp.default(tag, prop)) {
45
- output[prop] = input[prop];
44
+ const value = input[prop];
45
+ const isNestedContextObject = value !== null && typeof value === "object" && !Array.isArray(value);
46
+ const resolved = api.dictionary.resolve(prop);
47
+ const hasDescriptor = Boolean(resolved.descriptor);
48
+ const isCssProp = (0, _boss_css_is_css_prop.default)(tag, prop);
49
+ if (ignoredProps.has(prop) || require_isDOMProp.default(tag, prop) || !isCssProp && !hasDescriptor && !isNestedContextObject) {
50
+ output[prop] = value;
46
51
  delete input[prop];
47
52
  continue;
48
53
  }
49
54
  if (typeof input[prop] === "function") {
50
- if (isClassnameFirst && (0, _boss_css_is_css_prop.default)(tag, prop)) continue;
55
+ if (isClassnameFirst) continue;
51
56
  input[prop] = input[prop]();
52
57
  }
53
58
  }
@@ -39,13 +39,18 @@ const onBrowserObjectStart = (api, { input, tag = "div", contexts = [], output =
39
39
  delete input[prop];
40
40
  continue;
41
41
  }
42
- if (ignoredProps.has(prop) || isDOMProp(tag, prop)) {
43
- output[prop] = input[prop];
42
+ const value = input[prop];
43
+ const isNestedContextObject = value !== null && typeof value === "object" && !Array.isArray(value);
44
+ const resolved = api.dictionary.resolve(prop);
45
+ const hasDescriptor = Boolean(resolved.descriptor);
46
+ const isCssProp = isCSSProp(tag, prop);
47
+ if (ignoredProps.has(prop) || isDOMProp(tag, prop) || !isCssProp && !hasDescriptor && !isNestedContextObject) {
48
+ output[prop] = value;
44
49
  delete input[prop];
45
50
  continue;
46
51
  }
47
52
  if (typeof input[prop] === "function") {
48
- if (isClassnameFirst && isCSSProp(tag, prop)) continue;
53
+ if (isClassnameFirst) continue;
49
54
  input[prop] = input[prop]();
50
55
  }
51
56
  }
@@ -43,8 +43,7 @@ function resolveStyleTag(input) {
43
43
  function factory(tag) {
44
44
  return function $$(props, ref, ...restArgs) {
45
45
  const currentApi = getApi();
46
- if (tag || ref !== void 0) {
47
- let tagName = tag;
46
+ if (tag !== void 0 || ref !== void 0) {
48
47
  const input = props ?? {};
49
48
  const { children, as, ...rest } = input;
50
49
  const runtimeApi = currentApi.runtimeApi;
@@ -56,12 +55,15 @@ function factory(tag) {
56
55
  if (applyRef) applyRef(rest, ref);
57
56
  else rest.ref = ref;
58
57
  }
59
- const asTag = typeof as === "string" ? as : void 0;
60
- const displayName = asTag || tagName;
61
- tagName = asTag || tagName || "div";
62
- const Component = createComponent(tagName);
63
- Component.displayName = displayName ? "$$." + displayName : "$$";
64
- const output = resolveBossOutput(rest, tagName);
58
+ const asBossTag = as && typeof as === "function" && typeof as.__bossTag === "string" ? as.__bossTag : void 0;
59
+ const styleTag = (typeof as === "string" ? as : asBossTag) ?? (typeof tag === "string" ? tag : void 0) ?? "div";
60
+ const renderTarget = as ?? tag ?? "div";
61
+ const Component = typeof renderTarget === "string" ? createComponent(renderTarget) : renderTarget;
62
+ if (typeof Component === "function" && typeof Component.__bossTag === "string") {
63
+ const displayName = typeof as === "string" ? as : typeof tag === "string" ? tag : styleTag;
64
+ Component.displayName = displayName ? "$$." + displayName : "$$";
65
+ }
66
+ const output = resolveBossOutput(rest, styleTag);
65
67
  if (dev !== void 0) return currentApi.runtimeApi?.createElement(Component, output, resolvedChildren, dev);
66
68
  if (resolvedChildren === void 0) return currentApi.runtimeApi?.createElement(Component, output);
67
69
  return currentApi.runtimeApi?.createElement(Component, output, resolvedChildren);
@@ -43,8 +43,7 @@ function resolveStyleTag(input) {
43
43
  function factory(tag) {
44
44
  return function $$(props, ref, ...restArgs) {
45
45
  const currentApi = getApi();
46
- if (tag || ref !== void 0) {
47
- let tagName = tag;
46
+ if (tag !== void 0 || ref !== void 0) {
48
47
  const input = props ?? {};
49
48
  const { children, as, ...rest } = input;
50
49
  const runtimeApi = currentApi.runtimeApi;
@@ -56,12 +55,15 @@ function factory(tag) {
56
55
  if (applyRef) applyRef(rest, ref);
57
56
  else rest.ref = ref;
58
57
  }
59
- const asTag = typeof as === "string" ? as : void 0;
60
- const displayName = asTag || tagName;
61
- tagName = asTag || tagName || "div";
62
- const Component = createComponent(tagName);
63
- Component.displayName = displayName ? "$$." + displayName : "$$";
64
- const output = resolveBossOutput(rest, tagName);
58
+ const asBossTag = as && typeof as === "function" && typeof as.__bossTag === "string" ? as.__bossTag : void 0;
59
+ const styleTag = (typeof as === "string" ? as : asBossTag) ?? (typeof tag === "string" ? tag : void 0) ?? "div";
60
+ const renderTarget = as ?? tag ?? "div";
61
+ const Component = typeof renderTarget === "string" ? createComponent(renderTarget) : renderTarget;
62
+ if (typeof Component === "function" && typeof Component.__bossTag === "string") {
63
+ const displayName = typeof as === "string" ? as : typeof tag === "string" ? tag : styleTag;
64
+ Component.displayName = displayName ? "$$." + displayName : "$$";
65
+ }
66
+ const output = resolveBossOutput(rest, styleTag);
65
67
  if (dev !== void 0) return currentApi.runtimeApi?.createElement(Component, output, resolvedChildren, dev);
66
68
  if (resolvedChildren === void 0) return currentApi.runtimeApi?.createElement(Component, output);
67
69
  return currentApi.runtimeApi?.createElement(Component, output, resolvedChildren);
@@ -64,7 +64,8 @@ const onBrowserObjectStart = (api, { input }) => {
64
64
  else mutableInput[prop] = toTokenVar(path);
65
65
  } else if (typeof prop === "string") {
66
66
  const rawValue = mutableInput[prop];
67
- if (typeof rawValue !== "string") continue;
67
+ if (typeof rawValue !== "string" && typeof rawValue !== "number") continue;
68
+ const rawTokenKey = String(rawValue);
68
69
  const dashProp = api.camelCaseToDash?.(prop) ?? prop;
69
70
  const groupCandidates = [];
70
71
  const seen = /* @__PURE__ */ new Set();
@@ -77,8 +78,8 @@ const onBrowserObjectStart = (api, { input }) => {
77
78
  for (const group of require_propMap.getTokenGroupsForProp(dashProp)) addCandidate(group);
78
79
  addCandidate(prop);
79
80
  addCandidate(dashProp);
80
- const groupName = groupCandidates.find((group) => tokenPaths.has(`${group}.${rawValue}`));
81
- if (groupName && !isClassnameFirst) mutableInput[prop] = toTokenVar(`${groupName}.${rawValue.replace("$$.token.", "")}`);
81
+ const groupName = groupCandidates.find((group) => tokenPaths.has(`${group}.${rawTokenKey}`));
82
+ if (groupName && !isClassnameFirst) mutableInput[prop] = toTokenVar(`${groupName}.${rawTokenKey.replace("$$.token.", "")}`);
82
83
  }
83
84
  }
84
85
  };
@@ -64,7 +64,8 @@ const onBrowserObjectStart = (api, { input }) => {
64
64
  else mutableInput[prop] = toTokenVar(path);
65
65
  } else if (typeof prop === "string") {
66
66
  const rawValue = mutableInput[prop];
67
- if (typeof rawValue !== "string") continue;
67
+ if (typeof rawValue !== "string" && typeof rawValue !== "number") continue;
68
+ const rawTokenKey = String(rawValue);
68
69
  const dashProp = api.camelCaseToDash?.(prop) ?? prop;
69
70
  const groupCandidates = [];
70
71
  const seen = /* @__PURE__ */ new Set();
@@ -77,8 +78,8 @@ const onBrowserObjectStart = (api, { input }) => {
77
78
  for (const group of getTokenGroupsForProp(dashProp)) addCandidate(group);
78
79
  addCandidate(prop);
79
80
  addCandidate(dashProp);
80
- const groupName = groupCandidates.find((group) => tokenPaths.has(`${group}.${rawValue}`));
81
- if (groupName && !isClassnameFirst) mutableInput[prop] = toTokenVar(`${groupName}.${rawValue.replace("$$.token.", "")}`);
81
+ const groupName = groupCandidates.find((group) => tokenPaths.has(`${group}.${rawTokenKey}`));
82
+ if (groupName && !isClassnameFirst) mutableInput[prop] = toTokenVar(`${groupName}.${rawTokenKey.replace("$$.token.", "")}`);
82
83
  }
83
84
  }
84
85
  };
@@ -98,7 +98,8 @@ const getTokenPath = (api, prop, value) => {
98
98
  path: value.replace("$$.token.", ""),
99
99
  source: "group"
100
100
  };
101
- if (typeof value !== "string") return null;
101
+ if (typeof value !== "string" && typeof value !== "number") return null;
102
+ const rawTokenKey = String(value);
102
103
  const { groups } = getTokenState(api);
103
104
  const dashProp = api?.camelCaseToDash ? api.camelCaseToDash(prop) : prop;
104
105
  const groupCandidates = [];
@@ -113,10 +114,9 @@ const getTokenPath = (api, prop, value) => {
113
114
  addCandidate(prop);
114
115
  addCandidate(dashProp);
115
116
  if (!groupCandidates.length) return null;
116
- if (typeof value !== "string") return null;
117
- const tokenAlphaCandidate = parseTokenAlphaValue(value);
117
+ const tokenAlphaCandidate = typeof value === "string" ? parseTokenAlphaValue(value) : null;
118
118
  const baseParts = tokenAlphaCandidate ? tokenAlphaCandidate.base.split(".") : [];
119
- const rawParts = value.split(".");
119
+ const rawParts = rawTokenKey.split(".");
120
120
  const colorTokens = groups?.color;
121
121
  for (const group of groupCandidates) {
122
122
  const values = groups?.[group];
@@ -133,12 +133,12 @@ const getTokenPath = (api, prop, value) => {
133
133
  };
134
134
  }
135
135
  if (resolveTokenParts(values, rawParts) !== void 0) return {
136
- path: `${group}.${value}`,
136
+ path: `${group}.${rawTokenKey}`,
137
137
  source: "prop",
138
138
  values
139
139
  };
140
- if (value in values) return {
141
- path: `${group}.${value}`,
140
+ if (rawTokenKey in values) return {
141
+ path: `${group}.${rawTokenKey}`,
142
142
  source: "prop",
143
143
  values
144
144
  };
@@ -98,7 +98,8 @@ const getTokenPath = (api, prop, value) => {
98
98
  path: value.replace("$$.token.", ""),
99
99
  source: "group"
100
100
  };
101
- if (typeof value !== "string") return null;
101
+ if (typeof value !== "string" && typeof value !== "number") return null;
102
+ const rawTokenKey = String(value);
102
103
  const { groups } = getTokenState(api);
103
104
  const dashProp = api?.camelCaseToDash ? api.camelCaseToDash(prop) : prop;
104
105
  const groupCandidates = [];
@@ -113,10 +114,9 @@ const getTokenPath = (api, prop, value) => {
113
114
  addCandidate(prop);
114
115
  addCandidate(dashProp);
115
116
  if (!groupCandidates.length) return null;
116
- if (typeof value !== "string") return null;
117
- const tokenAlphaCandidate = parseTokenAlphaValue(value);
117
+ const tokenAlphaCandidate = typeof value === "string" ? parseTokenAlphaValue(value) : null;
118
118
  const baseParts = tokenAlphaCandidate ? tokenAlphaCandidate.base.split(".") : [];
119
- const rawParts = value.split(".");
119
+ const rawParts = rawTokenKey.split(".");
120
120
  const colorTokens = groups?.color;
121
121
  for (const group of groupCandidates) {
122
122
  const values = groups?.[group];
@@ -133,12 +133,12 @@ const getTokenPath = (api, prop, value) => {
133
133
  };
134
134
  }
135
135
  if (resolveTokenParts(values, rawParts) !== void 0) return {
136
- path: `${group}.${value}`,
136
+ path: `${group}.${rawTokenKey}`,
137
137
  source: "prop",
138
138
  values
139
139
  };
140
- if (value in values) return {
141
- path: `${group}.${value}`,
140
+ if (rawTokenKey in values) return {
141
+ path: `${group}.${rawTokenKey}`,
142
142
  source: "prop",
143
143
  values
144
144
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boss-css",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Polymorphic, usage-driven CSS-in-JS.",
5
5
  "bin": {
6
6
  "boss": "./dist/cli/index.cjs",