@ingram-tech/nk-dev 0.16.0 → 0.16.1

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.
@@ -22,22 +22,33 @@
22
22
  // convention on these sites (`render={<Link href={...} />}`). A variable,
23
23
  // call or conditional is not followed: the unusual cases fall out for free
24
24
  // instead of needing an allowlist of innocents.
25
- // * `render={<button />}` (the lowercase intrinsic) is correct as-is.
25
+ // * `render={<button />}` is correct as-is, and so is a component named
26
+ // `*Button`: that is Base UI's own button primitive or a wrapper on it,
27
+ // which renders a native <button>.
26
28
  // * `nativeButton={false}` anywhere on the element clears it. Any other
27
29
  // value, or a spread that might carry one, still reports: a spread is not
28
30
  // an explicit `nativeButton={false}`.
29
31
  //
30
- // Which components count as button-like: the ones Base UI itself builds on
31
- // `useButton` are Button, every *Trigger, *Close and *Item, plus Checkbox/Radio/
32
- // Switch/Toggle/Tab and the NumberField steppers. Matching all of those would
33
- // mean matching `Item`, a name too generic to key on outside Base UI, so the
34
- // set here is the suffixes that are both unambiguous and where a `render` of a
35
- // link is the common mistake: `Button` (Base UI's own, and every wrapper named
36
- // after it) and `Trigger`. Add a suffix below if a site hits one of the others.
32
+ // Which components count: only the ones that actually accept `nativeButton`.
33
+ // In @base-ui/react 1.8.0 that is Button, PopoverTrigger, Switch and the menu
34
+ // items; every other *Trigger builds on useButton internally but does not
35
+ // expose the prop, so demanding it there produces code that does not compile.
36
+ // An earlier revision keyed on the `Button`/`Trigger` name suffixes and was
37
+ // wrong on both counts: it reported design-system Buttons (which render a
38
+ // native <button>) and Triggers that have no such prop.
39
+ //
40
+ // The host must also be Base UI's own component. A locally defined
41
+ // `SidebarMenuButton` shares the name and takes no such prop, so the name list
42
+ // below is deliberately short and exact rather than suffix-matched.
37
43
 
38
44
  import { fileUsesBaseUi } from "./base-ui-project.js";
39
45
 
40
- const BUTTON_LIKE_SUFFIXES = ["Button", "Trigger"];
46
+ const NATIVE_BUTTON_PROP_COMPONENTS = new Set([
47
+ "Button",
48
+ "PopoverTrigger",
49
+ "Switch",
50
+ "MenuItem",
51
+ ]);
41
52
 
42
53
  /** `<Foo>` -> "Foo", `<Menu.Trigger>` -> "Trigger", otherwise null. */
43
54
  const componentNameOf = (opening) => {
@@ -49,10 +60,21 @@ const componentNameOf = (opening) => {
49
60
  return null;
50
61
  };
51
62
 
52
- const isButtonLike = (name) =>
53
- name !== null &&
54
- /^[A-Z]/.test(name) &&
55
- BUTTON_LIKE_SUFFIXES.some((suffix) => name.endsWith(suffix));
63
+ /**
64
+ * A render target that is itself a button. The lowercase intrinsic is the
65
+ * obvious one; a component named `*Button` is Base UI's own primitive or a
66
+ * wrapper around it, and renders a native <button> too, so requiring
67
+ * `nativeButton={false}` there would be wrong twice over: the element is
68
+ * native, and Base UI logs the inverse warning when the prop lies about it.
69
+ *
70
+ * The known gap is a `*Button` wrapper that renders an anchor (a LinkButton).
71
+ * Those set `nativeButton={false}` on their own inner button, so the mistake
72
+ * is contained in the wrapper rather than at every call site.
73
+ */
74
+ const rendersNativeButton = (name) =>
75
+ name === "button" || (/^[A-Z]/.test(name) && name.endsWith("Button"));
76
+
77
+ const isButtonLike = (name) => name !== null && NATIVE_BUTTON_PROP_COMPONENTS.has(name);
56
78
 
57
79
  /** The JSX element literal passed to `render`, or null. */
58
80
  const renderedElement = (attribute) => {
@@ -101,8 +123,7 @@ const baseUiNativeButton = {
101
123
  if (render === null) return;
102
124
 
103
125
  const rendered = componentNameOf(render.openingElement);
104
- // The lowercase intrinsic `button` is exactly what the default wants.
105
- if (rendered === null || rendered === "button") return;
126
+ if (rendered === null || rendersNativeButton(rendered)) return;
106
127
 
107
128
  context.report({
108
129
  node: render,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ingram-tech/nk-dev",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "The nextkit dev toolchain in one package: the `nk` CLI plus shared oxlint/oxfmt, TypeScript, and Vitest config, the format-on-commit hook, and the AI agent guide. `nk init` scaffolds a site to use it.",
5
5
  "license": "MIT",
6
6
  "type": "module",