@pixpilot/shadcn-ui 0.17.0 → 0.19.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/dist/Select.cjs CHANGED
@@ -8,13 +8,38 @@ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
8
8
 
9
9
  //#region src/Select.tsx
10
10
  function Select(props) {
11
- const { options, value = "", onChange, placeholder, contentProps,...restProps } = props;
11
+ const { options, value = "", onChange, placeholder, contentProps, keyboardMode = "dropdown", open: openProp, onOpenChange: onOpenChangeProp,...restProps } = props;
12
+ const [uncontrolledOpen, setUncontrolledOpen] = react.default.useState(false);
13
+ const open = openProp ?? uncontrolledOpen;
14
+ const handleOpenChange = (nextOpen) => {
15
+ if (openProp === void 0) setUncontrolledOpen(nextOpen);
16
+ onOpenChangeProp?.(nextOpen);
17
+ };
18
+ const handleTriggerKeyDown = (event) => {
19
+ if (keyboardMode !== "cycle") return;
20
+ if (open) return;
21
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
22
+ event.preventDefault();
23
+ event.stopPropagation();
24
+ if (!options || options.length === 0) return;
25
+ const currentIndex = options.findIndex((option) => String(option.value) === value);
26
+ const optionCount = options.length;
27
+ let nextIndex = 0;
28
+ if (event.key === "ArrowDown") nextIndex = currentIndex >= 0 ? (currentIndex + 1) % optionCount : 0;
29
+ else nextIndex = currentIndex >= 0 ? (currentIndex - 1 + optionCount) % optionCount : optionCount - 1;
30
+ const nextValue = String(options[nextIndex]?.value ?? "");
31
+ if (!nextValue || nextValue === value) return;
32
+ onChange?.(nextValue);
33
+ };
12
34
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn.Select, {
13
35
  value,
14
36
  onValueChange: onChange,
37
+ open,
38
+ onOpenChange: handleOpenChange,
15
39
  ...restProps,
16
40
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.SelectTrigger, {
17
41
  className: "w-full",
42
+ onKeyDown: handleTriggerKeyDown,
18
43
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.SelectValue, { placeholder })
19
44
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.SelectContent, {
20
45
  ...contentProps,
package/dist/Select.d.cts CHANGED
@@ -13,6 +13,7 @@ type BaseSelectProps = {
13
13
  value?: string;
14
14
  onChange?: (value: string) => void;
15
15
  placeholder?: string;
16
+ keyboardMode?: 'cycle' | 'dropdown';
16
17
  } & Omit<ComponentProps<typeof Select>, 'value' | 'onValueChange' | 'children'>;
17
18
  declare function Select$1(props: BaseSelectProps): react_jsx_runtime3.JSX.Element;
18
19
  //#endregion
package/dist/Select.d.ts CHANGED
@@ -13,6 +13,7 @@ type BaseSelectProps = {
13
13
  value?: string;
14
14
  onChange?: (value: string) => void;
15
15
  placeholder?: string;
16
+ keyboardMode?: 'cycle' | 'dropdown';
16
17
  } & Omit<ComponentProps<typeof Select>, 'value' | 'onValueChange' | 'children'>;
17
18
  declare function Select$1(props: BaseSelectProps): react_jsx_runtime3.JSX.Element;
18
19
  //#endregion
package/dist/Select.js CHANGED
@@ -4,13 +4,38 @@ import { jsx, jsxs } from "react/jsx-runtime";
4
4
 
5
5
  //#region src/Select.tsx
6
6
  function Select$1(props) {
7
- const { options, value = "", onChange, placeholder, contentProps,...restProps } = props;
7
+ const { options, value = "", onChange, placeholder, contentProps, keyboardMode = "dropdown", open: openProp, onOpenChange: onOpenChangeProp,...restProps } = props;
8
+ const [uncontrolledOpen, setUncontrolledOpen] = React.useState(false);
9
+ const open = openProp ?? uncontrolledOpen;
10
+ const handleOpenChange = (nextOpen) => {
11
+ if (openProp === void 0) setUncontrolledOpen(nextOpen);
12
+ onOpenChangeProp?.(nextOpen);
13
+ };
14
+ const handleTriggerKeyDown = (event) => {
15
+ if (keyboardMode !== "cycle") return;
16
+ if (open) return;
17
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
18
+ event.preventDefault();
19
+ event.stopPropagation();
20
+ if (!options || options.length === 0) return;
21
+ const currentIndex = options.findIndex((option) => String(option.value) === value);
22
+ const optionCount = options.length;
23
+ let nextIndex = 0;
24
+ if (event.key === "ArrowDown") nextIndex = currentIndex >= 0 ? (currentIndex + 1) % optionCount : 0;
25
+ else nextIndex = currentIndex >= 0 ? (currentIndex - 1 + optionCount) % optionCount : optionCount - 1;
26
+ const nextValue = String(options[nextIndex]?.value ?? "");
27
+ if (!nextValue || nextValue === value) return;
28
+ onChange?.(nextValue);
29
+ };
8
30
  return /* @__PURE__ */ jsxs(Select, {
9
31
  value,
10
32
  onValueChange: onChange,
33
+ open,
34
+ onOpenChange: handleOpenChange,
11
35
  ...restProps,
12
36
  children: [/* @__PURE__ */ jsx(SelectTrigger, {
13
37
  className: "w-full",
38
+ onKeyDown: handleTriggerKeyDown,
14
39
  children: /* @__PURE__ */ jsx(SelectValue, { placeholder })
15
40
  }), /* @__PURE__ */ jsx(SelectContent, {
16
41
  ...contentProps,
@@ -1,10 +1,10 @@
1
1
  import { FileUploadInlineProps } from "./types.cjs";
2
- import * as react_jsx_runtime8 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime7 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/file-upload-inline/FileUploadInline.d.ts
5
5
  /**
6
6
  * FileUploadInline - An inline file upload component using FileUpload primitives
7
7
  */
8
- declare function FileUploadInline(props: FileUploadInlineProps): react_jsx_runtime8.JSX.Element;
8
+ declare function FileUploadInline(props: FileUploadInlineProps): react_jsx_runtime7.JSX.Element;
9
9
  //#endregion
10
10
  export { FileUploadInline };
@@ -1,10 +1,10 @@
1
1
  import { FileUploadInlineProps } from "./types.js";
2
- import * as react_jsx_runtime7 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/file-upload-inline/FileUploadInline.d.ts
5
5
  /**
6
6
  * FileUploadInline - An inline file upload component using FileUpload primitives
7
7
  */
8
- declare function FileUploadInline(props: FileUploadInlineProps): react_jsx_runtime7.JSX.Element;
8
+ declare function FileUploadInline(props: FileUploadInlineProps): react_jsx_runtime8.JSX.Element;
9
9
  //#endregion
10
10
  export { FileUploadInline };
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime7 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
2
2
  import { InputProps } from "@pixpilot/shadcn";
3
3
  import * as React$1 from "react";
4
4
 
@@ -10,6 +10,6 @@ type InputProps$1 = InputProps & {
10
10
  prefixClassName?: string;
11
11
  suffixClassName?: string;
12
12
  };
13
- declare function Input(props: InputProps$1): react_jsx_runtime7.JSX.Element;
13
+ declare function Input(props: InputProps$1): react_jsx_runtime8.JSX.Element;
14
14
  //#endregion
15
15
  export { Input, InputProps$1 as InputProps };
@@ -1,6 +1,6 @@
1
1
  import { InputProps } from "@pixpilot/shadcn";
2
2
  import * as React$1 from "react";
3
- import * as react_jsx_runtime8 from "react/jsx-runtime";
3
+ import * as react_jsx_runtime7 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/input/Input.d.ts
6
6
  type InputProps$1 = InputProps & {
@@ -10,6 +10,6 @@ type InputProps$1 = InputProps & {
10
10
  prefixClassName?: string;
11
11
  suffixClassName?: string;
12
12
  };
13
- declare function Input$1(props: InputProps$1): react_jsx_runtime8.JSX.Element;
13
+ declare function Input$1(props: InputProps$1): react_jsx_runtime7.JSX.Element;
14
14
  //#endregion
15
15
  export { Input$1 as Input, InputProps$1 as InputProps };
@@ -7,8 +7,8 @@ let react_jsx_runtime = require("react/jsx-runtime");
7
7
  react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
8
8
 
9
9
  //#region src/layout/Layout.tsx
10
- const Layout = react.default.forwardRef(({ className,...props }, ref) => {
11
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10
+ const Layout = react.default.forwardRef(({ className, as: Component = "div",...props }, ref) => {
11
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
12
12
  ref,
13
13
  className: (0, __pixpilot_shadcn.cn)("flex w-full flex-col overflow-hidden", "h-dvh", "max-h-full", className),
14
14
  ...props
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
2
 
3
3
  //#region src/layout/Layout.d.ts
4
- interface LayoutProps extends React.HTMLAttributes<HTMLDivElement> {}
4
+ interface LayoutProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ as?: React.ElementType;
6
+ }
5
7
  declare const Layout: React.ForwardRefExoticComponent<LayoutProps & React.RefAttributes<HTMLDivElement>>;
6
8
  //#endregion
7
9
  export { Layout, LayoutProps };
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
2
 
3
3
  //#region src/layout/Layout.d.ts
4
- interface LayoutProps extends React.HTMLAttributes<HTMLDivElement> {}
4
+ interface LayoutProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ as?: React.ElementType;
6
+ }
5
7
  declare const Layout: React.ForwardRefExoticComponent<LayoutProps & React.RefAttributes<HTMLDivElement>>;
6
8
  //#endregion
7
9
  export { Layout, LayoutProps };
@@ -3,8 +3,8 @@ import React from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
 
5
5
  //#region src/layout/Layout.tsx
6
- const Layout = React.forwardRef(({ className,...props }, ref) => {
7
- return /* @__PURE__ */ jsx("div", {
6
+ const Layout = React.forwardRef(({ className, as: Component = "div",...props }, ref) => {
7
+ return /* @__PURE__ */ jsx(Component, {
8
8
  ref,
9
9
  className: cn("flex w-full flex-col overflow-hidden", "h-dvh", "max-h-full", className),
10
10
  ...props
@@ -7,7 +7,7 @@ let react_jsx_runtime = require("react/jsx-runtime");
7
7
  react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
8
8
 
9
9
  //#region src/layout/LayoutFooter.tsx
10
- const LayoutFooter = react.default.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10
+ const LayoutFooter = react.default.forwardRef(({ className, as: Component = "div",...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
11
11
  ...props,
12
12
  className: (0, __pixpilot_shadcn.cn)(className),
13
13
  ref
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
2
 
3
3
  //#region src/layout/LayoutFooter.d.ts
4
- interface LayoutFooterProps extends React.HTMLAttributes<HTMLDivElement> {}
4
+ interface LayoutFooterProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ as?: React.ElementType;
6
+ }
5
7
  declare const LayoutFooter: React.ForwardRefExoticComponent<LayoutFooterProps & React.RefAttributes<HTMLDivElement>>;
6
8
  //#endregion
7
9
  export { LayoutFooter, LayoutFooterProps };
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
2
 
3
3
  //#region src/layout/LayoutFooter.d.ts
4
- interface LayoutFooterProps extends React.HTMLAttributes<HTMLDivElement> {}
4
+ interface LayoutFooterProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ as?: React.ElementType;
6
+ }
5
7
  declare const LayoutFooter: React.ForwardRefExoticComponent<LayoutFooterProps & React.RefAttributes<HTMLDivElement>>;
6
8
  //#endregion
7
9
  export { LayoutFooter, LayoutFooterProps };
@@ -3,7 +3,7 @@ import React from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
 
5
5
  //#region src/layout/LayoutFooter.tsx
6
- const LayoutFooter = React.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("div", {
6
+ const LayoutFooter = React.forwardRef(({ className, as: Component = "div",...props }, ref) => /* @__PURE__ */ jsx(Component, {
7
7
  ...props,
8
8
  className: cn(className),
9
9
  ref
@@ -7,7 +7,7 @@ let react_jsx_runtime = require("react/jsx-runtime");
7
7
  react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
8
8
 
9
9
  //#region src/layout/LayoutHeader.tsx
10
- const LayoutHeader = react.default.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10
+ const LayoutHeader = react.default.forwardRef(({ className, as: Component = "div",...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
11
11
  ...props,
12
12
  className: (0, __pixpilot_shadcn.cn)(className),
13
13
  ref
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
2
 
3
3
  //#region src/layout/LayoutHeader.d.ts
4
- interface LayoutHeaderProps extends React.HTMLAttributes<HTMLDivElement> {}
4
+ interface LayoutHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ as?: React.ElementType;
6
+ }
5
7
  declare const LayoutHeader: React.ForwardRefExoticComponent<LayoutHeaderProps & React.RefAttributes<HTMLDivElement>>;
6
8
  //#endregion
7
9
  export { LayoutHeader, LayoutHeaderProps };
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
2
 
3
3
  //#region src/layout/LayoutHeader.d.ts
4
- interface LayoutHeaderProps extends React.HTMLAttributes<HTMLDivElement> {}
4
+ interface LayoutHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ as?: React.ElementType;
6
+ }
5
7
  declare const LayoutHeader: React.ForwardRefExoticComponent<LayoutHeaderProps & React.RefAttributes<HTMLDivElement>>;
6
8
  //#endregion
7
9
  export { LayoutHeader, LayoutHeaderProps };
@@ -3,7 +3,7 @@ import React from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
 
5
5
  //#region src/layout/LayoutHeader.tsx
6
- const LayoutHeader = React.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("div", {
6
+ const LayoutHeader = React.forwardRef(({ className, as: Component = "div",...props }, ref) => /* @__PURE__ */ jsx(Component, {
7
7
  ...props,
8
8
  className: cn(className),
9
9
  ref
@@ -7,8 +7,8 @@ let react_jsx_runtime = require("react/jsx-runtime");
7
7
  react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
8
8
 
9
9
  //#region src/layout/LayoutMain.tsx
10
- const LayoutMain = react.default.forwardRef(({ autoScroll = true, className,...props }, ref) => {
11
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("main", {
10
+ const LayoutMain = react.default.forwardRef(({ autoScroll = true, className, as: Component = "div",...props }, ref) => {
11
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
12
12
  ref,
13
13
  className: (0, __pixpilot_shadcn.cn)("flex-1", { "overflow-auto": autoScroll }, className),
14
14
  ...props
@@ -1,9 +1,10 @@
1
1
  import React from "react";
2
2
 
3
3
  //#region src/layout/LayoutMain.d.ts
4
- interface LayoutMainProps extends React.HTMLAttributes<HTMLElement> {
4
+ interface LayoutMainProps extends React.HTMLAttributes<HTMLDivElement> {
5
5
  autoScroll?: boolean;
6
+ as?: React.ElementType;
6
7
  }
7
- declare const LayoutMain: React.ForwardRefExoticComponent<LayoutMainProps & React.RefAttributes<HTMLElement>>;
8
+ declare const LayoutMain: React.ForwardRefExoticComponent<LayoutMainProps & React.RefAttributes<HTMLDivElement>>;
8
9
  //#endregion
9
10
  export { LayoutMain, LayoutMainProps };
@@ -1,9 +1,10 @@
1
1
  import React from "react";
2
2
 
3
3
  //#region src/layout/LayoutMain.d.ts
4
- interface LayoutMainProps extends React.HTMLAttributes<HTMLElement> {
4
+ interface LayoutMainProps extends React.HTMLAttributes<HTMLDivElement> {
5
5
  autoScroll?: boolean;
6
+ as?: React.ElementType;
6
7
  }
7
- declare const LayoutMain: React.ForwardRefExoticComponent<LayoutMainProps & React.RefAttributes<HTMLElement>>;
8
+ declare const LayoutMain: React.ForwardRefExoticComponent<LayoutMainProps & React.RefAttributes<HTMLDivElement>>;
8
9
  //#endregion
9
10
  export { LayoutMain, LayoutMainProps };
@@ -3,8 +3,8 @@ import React from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
 
5
5
  //#region src/layout/LayoutMain.tsx
6
- const LayoutMain = React.forwardRef(({ autoScroll = true, className,...props }, ref) => {
7
- return /* @__PURE__ */ jsx("main", {
6
+ const LayoutMain = React.forwardRef(({ autoScroll = true, className, as: Component = "div",...props }, ref) => {
7
+ return /* @__PURE__ */ jsx(Component, {
8
8
  ref,
9
9
  className: cn("flex-1", { "overflow-auto": autoScroll }, className),
10
10
  ...props
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pixpilot/shadcn-ui",
3
3
  "type": "module",
4
- "version": "0.17.0",
4
+ "version": "0.19.0",
5
5
  "description": "Custom UI components and utilities built with shadcn/ui.",
6
6
  "author": "m.doaie <m.doaie@hotmail.com>",
7
7
  "license": "MIT",
@@ -58,9 +58,9 @@
58
58
  "tsdown": "^0.15.12",
59
59
  "typescript": "^5.9.3",
60
60
  "@internal/eslint-config": "0.3.0",
61
- "@internal/hooks": "0.0.0",
62
61
  "@internal/prettier-config": "0.0.1",
63
62
  "@internal/tsconfig": "0.1.0",
63
+ "@internal/hooks": "0.0.0",
64
64
  "@internal/tsdown-config": "0.1.0",
65
65
  "@internal/vitest-config": "0.1.0"
66
66
  },