@oneplatformdev/ui 0.0.1-beta.39 → 0.0.1-beta.40
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.
@@ -2,5 +2,5 @@ import { SelectProps } from '../Select';
|
|
2
2
|
import { FormRenderControlExtendProps } from '../Form';
|
3
3
|
import { FieldValues } from 'react-hook-form/dist/types/fields';
|
4
4
|
|
5
|
-
export interface FormSelectProps<Data extends FieldValues, ExtendOptionData> extends FormRenderControlExtendProps<Data>, SelectProps<ExtendOptionData
|
5
|
+
export interface FormSelectProps<Data extends FieldValues, ExtendOptionData> extends FormRenderControlExtendProps<Data>, Omit<SelectProps<ExtendOptionData>, 'onChange'>, Partial<Pick<SelectProps<ExtendOptionData>, 'onChange'>> {
|
6
6
|
}
|
package/Select/Select.mjs
CHANGED
@@ -1,59 +1,59 @@
|
|
1
1
|
import { jsxs as d, jsx as a } from "react/jsx-runtime";
|
2
2
|
import { Button as f } from "../Button/Button.mjs";
|
3
3
|
import "../Button/buttonVariants.mjs";
|
4
|
-
import { SelectRoot as
|
5
|
-
import { isValidReactElement as
|
4
|
+
import { SelectRoot as g, SelectContent as p, SelectTrigger as h, SelectValue as v, SelectItem as u } from "./SelectRoot.mjs";
|
5
|
+
import { isValidReactElement as c } from "@oneplatformdev/utils";
|
6
6
|
const S = (o) => {
|
7
|
-
const { placeholder:
|
8
|
-
return e && typeof e == "function" &&
|
7
|
+
const { placeholder: l, renderTrigger: e, slotProps: t } = o, n = /* @__PURE__ */ a(h, { ...(t == null ? void 0 : t.triggerProps) || {}, children: /* @__PURE__ */ a(v, { placeholder: l }) });
|
8
|
+
return e && typeof e == "function" && c(e(o, n)) ? e(o, n) : n;
|
9
9
|
}, C = (o) => {
|
10
|
-
const { renderOption:
|
11
|
-
return
|
10
|
+
const { renderOption: l, option: e, index: t, options: n, ...i } = o, r = /* @__PURE__ */ a(u, { value: e.value, children: e.label }, e.value);
|
11
|
+
return l && typeof l == "function" && c(l(
|
12
12
|
e,
|
13
|
+
t,
|
13
14
|
n,
|
14
|
-
|
15
|
-
{ ...c, options: l },
|
15
|
+
{ ...i, options: n },
|
16
16
|
r
|
17
|
-
)) ?
|
17
|
+
)) ? c(l(
|
18
18
|
e,
|
19
|
+
t,
|
19
20
|
n,
|
20
|
-
|
21
|
-
{ ...c, options: l },
|
21
|
+
{ ...i, options: n },
|
22
22
|
r
|
23
|
-
), u) ?
|
23
|
+
), u) ? c(l(
|
24
24
|
e,
|
25
|
+
t,
|
25
26
|
n,
|
26
|
-
|
27
|
-
{ ...c, options: l },
|
27
|
+
{ ...i, options: n },
|
28
28
|
r
|
29
|
-
)) : /* @__PURE__ */ a(u, { value: e.value, children:
|
29
|
+
)) : /* @__PURE__ */ a(u, { value: e.value, children: l(
|
30
30
|
e,
|
31
|
+
t,
|
31
32
|
n,
|
32
|
-
|
33
|
-
{ ...c, options: l },
|
33
|
+
{ ...i, options: n },
|
34
34
|
r
|
35
35
|
) }, e.value) : r;
|
36
36
|
}, T = (o) => {
|
37
37
|
const {
|
38
|
-
value:
|
38
|
+
value: l,
|
39
39
|
options: e,
|
40
|
-
onChange:
|
41
|
-
nullable:
|
42
|
-
clearLabel:
|
40
|
+
onChange: t,
|
41
|
+
nullable: n = !1,
|
42
|
+
clearLabel: i = "Clear",
|
43
43
|
disabled: r
|
44
44
|
} = o;
|
45
45
|
return /* @__PURE__ */ d(
|
46
|
-
|
46
|
+
g,
|
47
47
|
{
|
48
|
-
value:
|
49
|
-
onValueChange:
|
48
|
+
value: l,
|
49
|
+
onValueChange: t,
|
50
50
|
disabled: r,
|
51
51
|
children: [
|
52
52
|
/* @__PURE__ */ a(S, { ...o }),
|
53
|
-
/* @__PURE__ */ d(
|
54
|
-
|
55
|
-
|
56
|
-
}, children:
|
53
|
+
/* @__PURE__ */ d(p, { children: [
|
54
|
+
n && /* @__PURE__ */ a(f, { className: "w-full px-2", variant: "secondary", size: "sm", onClick: () => {
|
55
|
+
t("");
|
56
|
+
}, children: i }),
|
57
57
|
e.map((s, m) => /* @__PURE__ */ a(
|
58
58
|
C,
|
59
59
|
{
|
package/Select/Select.types.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
import { ReactNode } from 'react';
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
2
2
|
|
3
|
+
import * as SelectPrimitive from '@radix-ui/react-select';
|
3
4
|
export interface SelectOption<ExtendOptionData> {
|
4
5
|
value: string;
|
5
6
|
label?: ReactNode;
|
@@ -26,4 +27,9 @@ export interface SelectProps<ExtendOptionData> {
|
|
26
27
|
renderTrigger?: SelectRenderTrigger<ExtendOptionData>;
|
27
28
|
/** Render custom option. */
|
28
29
|
renderOption?: SelectRenderOption<ExtendOptionData>;
|
30
|
+
/** Select Slot props */
|
31
|
+
slotProps?: {
|
32
|
+
/** Select Default Trigger Props */
|
33
|
+
triggerProps?: ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>;
|
34
|
+
};
|
29
35
|
}
|