@kaushverse/pickify 1.0.3 → 1.0.4
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/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +15 -6
- package/dist/index.mjs +15 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -37,6 +37,7 @@ type Props = {
|
|
|
37
37
|
selectTextStyle?: TextStyle;
|
|
38
38
|
errorStyle?: TextStyle;
|
|
39
39
|
visible?: boolean;
|
|
40
|
+
setVisible?: (val: boolean) => void;
|
|
40
41
|
selectedValue: string;
|
|
41
42
|
options: Option[];
|
|
42
43
|
groups?: Group[];
|
|
@@ -54,7 +55,7 @@ type Props = {
|
|
|
54
55
|
onClose: () => void;
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
declare function PickerModal({ visible, selectedValue, options, groups, styles, theme, renderTab, renderItem, renderContainer, onSelect, onClose, renderIcon, label, placeholder, error, labelStyle, selectBoxStyle, selectTextStyle, errorStyle, }: Props & {
|
|
58
|
+
declare function PickerModal({ visible, selectedValue, options, groups, styles, theme, renderTab, renderItem, renderContainer, onSelect, onClose, renderIcon, label, placeholder, error, labelStyle, selectBoxStyle, selectTextStyle, errorStyle, setVisible }: Props & {
|
|
58
59
|
label?: string;
|
|
59
60
|
placeholder?: string;
|
|
60
61
|
error?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ type Props = {
|
|
|
37
37
|
selectTextStyle?: TextStyle;
|
|
38
38
|
errorStyle?: TextStyle;
|
|
39
39
|
visible?: boolean;
|
|
40
|
+
setVisible?: (val: boolean) => void;
|
|
40
41
|
selectedValue: string;
|
|
41
42
|
options: Option[];
|
|
42
43
|
groups?: Group[];
|
|
@@ -54,7 +55,7 @@ type Props = {
|
|
|
54
55
|
onClose: () => void;
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
declare function PickerModal({ visible, selectedValue, options, groups, styles, theme, renderTab, renderItem, renderContainer, onSelect, onClose, renderIcon, label, placeholder, error, labelStyle, selectBoxStyle, selectTextStyle, errorStyle, }: Props & {
|
|
58
|
+
declare function PickerModal({ visible, selectedValue, options, groups, styles, theme, renderTab, renderItem, renderContainer, onSelect, onClose, renderIcon, label, placeholder, error, labelStyle, selectBoxStyle, selectTextStyle, errorStyle, setVisible }: Props & {
|
|
58
59
|
label?: string;
|
|
59
60
|
placeholder?: string;
|
|
60
61
|
error?: string;
|
package/dist/index.js
CHANGED
|
@@ -49,11 +49,12 @@ function PickerModal({
|
|
|
49
49
|
labelStyle,
|
|
50
50
|
selectBoxStyle,
|
|
51
51
|
selectTextStyle,
|
|
52
|
-
errorStyle
|
|
52
|
+
errorStyle,
|
|
53
|
+
setVisible
|
|
53
54
|
}) {
|
|
54
55
|
const [activeTab, setActiveTab] = (0, import_react.useState)(0);
|
|
55
56
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
56
|
-
const isControlled = visible !== void 0;
|
|
57
|
+
const isControlled = visible !== void 0 && setVisible !== void 0;
|
|
57
58
|
const isVisible = isControlled ? visible : open;
|
|
58
59
|
const hasGroups = groups.length > 0;
|
|
59
60
|
const currentOptions = hasGroups ? groups[activeTab]?.data || [] : options;
|
|
@@ -71,13 +72,21 @@ function PickerModal({
|
|
|
71
72
|
const all = hasGroups ? groups.flatMap((g) => g.data) : options;
|
|
72
73
|
return all.find((o) => o.value === selectedValue)?.label;
|
|
73
74
|
};
|
|
75
|
+
const handleOpen = () => {
|
|
76
|
+
if (isControlled) {
|
|
77
|
+
setVisible(true);
|
|
78
|
+
} else {
|
|
79
|
+
setOpen(true);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
74
82
|
const handleClose = () => {
|
|
75
|
-
|
|
83
|
+
if (isControlled) {
|
|
84
|
+
setVisible(false);
|
|
85
|
+
} else {
|
|
86
|
+
setOpen(false);
|
|
87
|
+
}
|
|
76
88
|
onClose?.();
|
|
77
89
|
};
|
|
78
|
-
const handleOpen = () => {
|
|
79
|
-
setOpen(true);
|
|
80
|
-
};
|
|
81
90
|
const content = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
82
91
|
import_react_native.View,
|
|
83
92
|
{
|
package/dist/index.mjs
CHANGED
|
@@ -29,11 +29,12 @@ function PickerModal({
|
|
|
29
29
|
labelStyle,
|
|
30
30
|
selectBoxStyle,
|
|
31
31
|
selectTextStyle,
|
|
32
|
-
errorStyle
|
|
32
|
+
errorStyle,
|
|
33
|
+
setVisible
|
|
33
34
|
}) {
|
|
34
35
|
const [activeTab, setActiveTab] = useState(0);
|
|
35
36
|
const [open, setOpen] = useState(false);
|
|
36
|
-
const isControlled = visible !== void 0;
|
|
37
|
+
const isControlled = visible !== void 0 && setVisible !== void 0;
|
|
37
38
|
const isVisible = isControlled ? visible : open;
|
|
38
39
|
const hasGroups = groups.length > 0;
|
|
39
40
|
const currentOptions = hasGroups ? groups[activeTab]?.data || [] : options;
|
|
@@ -51,13 +52,21 @@ function PickerModal({
|
|
|
51
52
|
const all = hasGroups ? groups.flatMap((g) => g.data) : options;
|
|
52
53
|
return all.find((o) => o.value === selectedValue)?.label;
|
|
53
54
|
};
|
|
55
|
+
const handleOpen = () => {
|
|
56
|
+
if (isControlled) {
|
|
57
|
+
setVisible(true);
|
|
58
|
+
} else {
|
|
59
|
+
setOpen(true);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
54
62
|
const handleClose = () => {
|
|
55
|
-
|
|
63
|
+
if (isControlled) {
|
|
64
|
+
setVisible(false);
|
|
65
|
+
} else {
|
|
66
|
+
setOpen(false);
|
|
67
|
+
}
|
|
56
68
|
onClose?.();
|
|
57
69
|
};
|
|
58
|
-
const handleOpen = () => {
|
|
59
|
-
setOpen(true);
|
|
60
|
-
};
|
|
61
70
|
const content = /* @__PURE__ */ jsxs(
|
|
62
71
|
View,
|
|
63
72
|
{
|
package/package.json
CHANGED