@pixpilot/shadcn-ui 0.18.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 +26 -1
- package/dist/Select.d.cts +1 -0
- package/dist/Select.d.ts +1 -0
- package/dist/Select.js +26 -1
- package/dist/file-upload/FileUpload.d.ts +2 -2
- package/dist/input/Input.d.ts +2 -2
- package/package.json +2 -2
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,7 +1,7 @@
|
|
|
1
1
|
import { FileUploadProps } from "./types/index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/file-upload/FileUpload.d.ts
|
|
5
|
-
declare function FileUpload(props: FileUploadProps):
|
|
5
|
+
declare function FileUpload(props: FileUploadProps): react_jsx_runtime6.JSX.Element;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { FileUpload };
|
package/dist/input/Input.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InputProps } from "@pixpilot/shadcn";
|
|
2
2
|
import * as React$1 from "react";
|
|
3
|
-
import * as
|
|
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):
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixpilot/shadcn-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "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
|
},
|