@lenso/primitives 0.7.0 → 0.8.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/README.md CHANGED
@@ -27,3 +27,8 @@ export function AppShell() {
27
27
  Use `@lenso/ui/sidebar` when you want the Lenso UI visual adapter. The registry also includes an editable Sidebar Recipe for Consumers that need structural ownership.
28
28
 
29
29
  Source and browser tests live under `packages/primitives/src/sidebar`. See the repository [architecture guide](../../docs/architecture.md) for the dependency boundary and the [contributing guide](../../CONTRIBUTING.md) for changes and release verification.
30
+
31
+ ## Command
32
+
33
+ `@lenso/primitives/command` provides unstyled command filtering, navigation and execution.
34
+ Use `@lenso/ui/command` for the styled Lenso component.
@@ -0,0 +1,25 @@
1
+ import { Autocomplete } from "@base-ui/react/autocomplete";
2
+ import { type RefAttributes } from "react";
3
+ export type CommandRootProps<Value> = Omit<Autocomplete.Root.Props<Value>, "inline" | "open" | "defaultOpen" | "onOpenChange" | "mode" | "filter" | "items" | "filteredItems"> & {
4
+ items?: readonly Value[];
5
+ filteredItems?: readonly Value[];
6
+ filter?: Autocomplete.Root.Props<Value>["filter"] | false;
7
+ };
8
+ /** An inline command list. Compose with Dialog when an overlay is needed. */
9
+ export declare function CommandRoot<Value>({ value, defaultValue, onValueChange, filter, autoHighlight, keepHighlight, readOnly, ...props }: CommandRootProps<Value>): import("react").JSX.Element;
10
+ export type CommandItemProps<Value = string> = Omit<Autocomplete.Item.Props, "value" | "onSelect"> & RefAttributes<HTMLDivElement> & {
11
+ value: Value;
12
+ onSelect?: (value: Value) => void;
13
+ };
14
+ export declare function CommandItem<Value = string>({ value, onClick, onSelect, ...props }: CommandItemProps<Value>): import("react").JSX.Element;
15
+ export type CommandInputProps = Autocomplete.Input.Props;
16
+ export declare function CommandInput({ onKeyDown, ...props }: CommandInputProps): import("react").JSX.Element;
17
+ export declare const CommandList: typeof Autocomplete.List;
18
+ export declare const CommandEmpty: typeof Autocomplete.Empty;
19
+ export declare const CommandGroup: typeof Autocomplete.Group;
20
+ export declare const CommandGroupLabel: typeof Autocomplete.GroupLabel;
21
+ export declare const CommandSeparator: typeof Autocomplete.Separator;
22
+ export declare const CommandCollection: typeof Autocomplete.Collection;
23
+ export declare const CommandStatus: typeof Autocomplete.Status;
24
+ export declare const CommandClear: typeof Autocomplete.Clear;
25
+ export declare const useCommandFilter: typeof Autocomplete.useFilter;
@@ -0,0 +1,16 @@
1
+ import { CommandRoot, CommandInput, CommandList, CommandItem, CommandEmpty, CommandGroup, CommandGroupLabel, CommandSeparator, CommandCollection, CommandStatus, CommandClear, useCommandFilter } from "./command.js";
2
+ export declare const Command: typeof CommandRoot & {
3
+ Root: typeof CommandRoot;
4
+ Input: typeof CommandInput;
5
+ List: typeof CommandList;
6
+ Item: typeof CommandItem;
7
+ Empty: typeof CommandEmpty;
8
+ Group: typeof CommandGroup;
9
+ GroupLabel: typeof CommandGroupLabel;
10
+ Separator: typeof CommandSeparator;
11
+ Collection: typeof CommandCollection;
12
+ Status: typeof CommandStatus;
13
+ Clear: typeof CommandClear;
14
+ useFilter: typeof useCommandFilter;
15
+ };
16
+ export * from "./command.js";
@@ -0,0 +1,76 @@
1
+ "use client";
2
+ import { Autocomplete } from "@base-ui/react/autocomplete";
3
+ import { createContext, useContext, useState } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/command/command.tsx
6
+ const CommandReadOnly = createContext(false);
7
+ /** An inline command list. Compose with Dialog when an overlay is needed. */
8
+ function CommandRoot({ value, defaultValue = "", onValueChange, filter, autoHighlight = "always", keepHighlight = true, readOnly = false, ...props }) {
9
+ const [query, setQuery] = useState(defaultValue);
10
+ return /* @__PURE__ */ jsx(CommandReadOnly, {
11
+ value: readOnly,
12
+ children: /* @__PURE__ */ jsx(Autocomplete.Root, {
13
+ ...props,
14
+ readOnly,
15
+ inline: true,
16
+ open: true,
17
+ autoHighlight,
18
+ keepHighlight,
19
+ filter: filter === false ? null : filter,
20
+ value: value ?? query,
21
+ onValueChange: (next, details) => {
22
+ if (details.reason === "item-press") {
23
+ details.cancel();
24
+ return;
25
+ }
26
+ onValueChange?.(next, details);
27
+ if (!details.isCanceled) setQuery(next);
28
+ }
29
+ })
30
+ });
31
+ }
32
+ function CommandItem({ value, onClick, onSelect, ...props }) {
33
+ const readOnly = useContext(CommandReadOnly);
34
+ return /* @__PURE__ */ jsx(Autocomplete.Item, {
35
+ ...props,
36
+ value,
37
+ onClick: (event) => {
38
+ onClick?.(event);
39
+ if (!readOnly && !event.defaultPrevented && !event.baseUIHandlerPrevented) onSelect?.(value);
40
+ }
41
+ });
42
+ }
43
+ function CommandInput({ onKeyDown, ...props }) {
44
+ return /* @__PURE__ */ jsx(Autocomplete.Input, {
45
+ ...props,
46
+ onKeyDown: (event) => {
47
+ onKeyDown?.(event);
48
+ if (event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) event.preventBaseUIHandler();
49
+ }
50
+ });
51
+ }
52
+ const CommandList = Autocomplete.List;
53
+ const CommandEmpty = Autocomplete.Empty;
54
+ const CommandGroup = Autocomplete.Group;
55
+ const CommandGroupLabel = Autocomplete.GroupLabel;
56
+ const CommandSeparator = Autocomplete.Separator;
57
+ const CommandCollection = Autocomplete.Collection;
58
+ const CommandStatus = Autocomplete.Status;
59
+ const CommandClear = Autocomplete.Clear;
60
+ const useCommandFilter = Autocomplete.useFilter;
61
+ // src/command/index.ts
62
+ const Command = Object.assign(CommandRoot, {
63
+ Root: CommandRoot,
64
+ Input: CommandInput,
65
+ List: CommandList,
66
+ Item: CommandItem,
67
+ Empty: CommandEmpty,
68
+ Group: CommandGroup,
69
+ GroupLabel: CommandGroupLabel,
70
+ Separator: CommandSeparator,
71
+ Collection: CommandCollection,
72
+ Status: CommandStatus,
73
+ Clear: CommandClear,
74
+ useFilter: useCommandFilter
75
+ });
76
+ export { Command, CommandClear, CommandCollection, CommandEmpty, CommandGroup, CommandGroupLabel, CommandInput, CommandItem, CommandList, CommandRoot, CommandSeparator, CommandStatus, useCommandFilter };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import * as React from "react";
3
3
  import { cellSelectionFeature, columnResizingFeature, columnSizingFeature, createSortedRowModel, functionalUpdate, makeStateUpdater, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_basic, sortFn_datetime, sortFn_text, tableFeatures, useTable } from "@tanstack/react-table";
4
- //#region src/data-grid/index.tsx
4
+ // src/data-grid/index.tsx
5
5
  const dataGridFeatures = tableFeatures({
6
6
  cellSelectionFeature,
7
7
  columnSizingFeature,
@@ -175,5 +175,4 @@ function useDataGrid({ rows, columns, getRowId, readOnly = false, rowSelection =
175
175
  ])
176
176
  };
177
177
  }
178
- //#endregion
179
178
  export { dataGridFeatures, useDataGrid };
@@ -3,7 +3,7 @@ import * as React from "react";
3
3
  import * as stylex from "@stylexjs/stylex";
4
4
  import { mergeProps } from "@base-ui/react/merge-props";
5
5
  import { useRender } from "@base-ui/react/use-render";
6
- //#region src/resize-handle/index.tsx
6
+ // src/resize-handle/index.tsx
7
7
  function clamp(value, min, max) {
8
8
  return Math.min(max, Math.max(min, value));
9
9
  }
@@ -176,5 +176,4 @@ function ResizeHandle({ disabled = false, inverted = false, max, min, onCollapse
176
176
  }
177
177
  });
178
178
  }
179
- //#endregion
180
179
  export { ResizeHandle };
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import * as React from "react";
3
+ import { jsx } from "react/jsx-runtime";
3
4
  import { mergeProps } from "@base-ui/react/merge-props";
4
5
  import { useRender } from "@base-ui/react/use-render";
5
6
  import { Button } from "@base-ui/react/button";
6
- import { jsx } from "react/jsx-runtime";
7
- //#region src/sidebar/index.tsx
7
+ // src/sidebar/index.tsx
8
8
  const SidebarContext = React.createContext(null);
9
9
  const SidebarGroupContext = React.createContext(null);
10
10
  function useSidebarController(part) {
@@ -298,5 +298,4 @@ const Sidebar = {
298
298
  Submenu: SidebarSubmenu,
299
299
  Trigger: SidebarTrigger
300
300
  };
301
- //#endregion
302
301
  export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarHeader, SidebarInset, SidebarItem, SidebarMenu, SidebarMenuItem, SidebarPanel, SidebarProvider, SidebarRail, SidebarRoot, SidebarSubmenu, SidebarTrigger };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenso/primitives",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Headless product primitives for Lenso UI.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -10,6 +10,7 @@
10
10
  },
11
11
  "files": [
12
12
  "dist",
13
+ "LICENSE",
13
14
  "README.md"
14
15
  ],
15
16
  "type": "module",
@@ -25,37 +26,37 @@
25
26
  "./sidebar": {
26
27
  "types": "./dist/sidebar/index.d.ts",
27
28
  "import": "./dist/sidebar/index.js"
29
+ },
30
+ "./command": {
31
+ "types": "./dist/command/index.d.ts",
32
+ "import": "./dist/command/index.js"
28
33
  }
29
34
  },
30
35
  "publishConfig": {
31
36
  "access": "public"
32
37
  },
38
+ "scripts": {
39
+ "build": "tsdown --config tsdown.config.ts && tsc -p tsconfig.build.json --declaration --emitDeclarationOnly --noEmit false --outDir dist",
40
+ "test": "bun test --preload ../../tests/setup/dom.ts src",
41
+ "typecheck": "bun check --no-script --noEmit"
42
+ },
33
43
  "dependencies": {
34
- "@tanstack/react-table": "9.2.4"
44
+ "@tanstack/react-table": "9.3.1"
35
45
  },
36
46
  "devDependencies": {
37
- "@base-ui/react": "1.7.0",
38
- "@stylexjs/stylex": "0.19.0",
39
- "@stylexjs/unplugin": "0.19.0",
40
- "@types/react": "19.2.18",
41
- "@vitest/browser-playwright": "4.1.10",
42
- "axe-core": "4.13.0",
43
- "playwright": "1.62.1",
44
- "react": "19.2.8",
45
- "react-dom": "19.2.8",
46
- "tsdown": "0.22.14",
47
- "typescript": "7.0.2",
48
- "vitest": "4.1.10",
49
- "vitest-browser-react": "2.2.0"
47
+ "@base-ui/react": "1.9.0",
48
+ "@stylexjs/stylex": "0.19.1",
49
+ "@types/bun": "1.4.4",
50
+ "@types/react": "19.3.0",
51
+ "@types/react-dom": "19.3.0",
52
+ "react": "19.3.1",
53
+ "react-dom": "19.3.1",
54
+ "tsdown": "0.23.7",
55
+ "typescript": "7.0.2"
50
56
  },
51
57
  "peerDependencies": {
52
58
  "@base-ui/react": ">=1.7.0 <2.0.0",
53
59
  "@stylexjs/stylex": ">=0.19.0 <1.0.0",
54
60
  "react": ">=19.2.0 <20.0.0"
55
- },
56
- "scripts": {
57
- "build": "tsdown --config tsdown.config.ts && tsc -p tsconfig.build.json --declaration --emitDeclarationOnly --noEmit false --outDir dist",
58
- "test": "vitest run --config vitest.config.ts",
59
- "typecheck": "tsc --noEmit"
60
61
  }
61
- }
62
+ }