@kaushverse/pickify 1.1.1 → 1.1.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React$1 from 'react';
3
- import { TextStyle, ViewStyle } from 'react-native';
3
+ import { TextStyle, ViewStyle, Animated } from 'react-native';
4
4
 
5
5
  type IconRenderer = (props: {
6
6
  name?: string;
@@ -37,7 +37,7 @@ type PickerStyles = {
37
37
  selectText?: TextStyle;
38
38
  error?: TextStyle;
39
39
  };
40
- type Props = {
40
+ type Props$1 = {
41
41
  labelStyle?: TextStyle;
42
42
  selectBoxStyle?: ViewStyle;
43
43
  selectTextStyle?: TextStyle;
@@ -57,7 +57,7 @@ type Props = {
57
57
  onClose: () => void;
58
58
  };
59
59
 
60
- declare function PickerModal({ visible, selectedValue, options, groups, styles, theme, renderTab, renderItem, renderContainer, onSelect, onClose, renderIcon, label, placeholder, error, labelStyle, selectBoxStyle, selectTextStyle, errorStyle, setVisible }: Props & {
60
+ declare function PickerModal({ visible, selectedValue, options, groups, styles, theme, renderTab, renderItem, renderContainer, onSelect, onClose, renderIcon, label, placeholder, error, labelStyle, selectBoxStyle, selectTextStyle, errorStyle, setVisible }: Props$1 & {
61
61
  label?: string;
62
62
  placeholder?: string;
63
63
  error?: string;
@@ -128,6 +128,36 @@ type MultiPickerProps = {
128
128
 
129
129
  declare function MultiPickerModal({ visible, setVisible, selectedValues, options, groups, onChange, label, placeholder, error, renderInputIcon, renderGroupIcon, renderItemIcon, styles, }: MultiPickerProps): react_jsx_runtime.JSX.Element;
130
130
 
131
+ type Action = {
132
+ icon: string;
133
+ onPress?: () => void;
134
+ navigateTo?: () => void;
135
+ color?: string;
136
+ iconColor?: string;
137
+ };
138
+ type FloatingButtonStyles = {
139
+ container?: ViewStyle;
140
+ mainButton?: ViewStyle;
141
+ secondaryButton?: ViewStyle;
142
+ };
143
+ type Props = {
144
+ actions: Action[];
145
+ mode?: "vertical" | "horizontal" | "circle";
146
+ radius?: number;
147
+ renderMainIcon?: IconRenderer;
148
+ renderItemIcon?: IconRenderer;
149
+ styles?: FloatingButtonStyles;
150
+ style?: ViewStyle;
151
+ mainIconName?: string;
152
+ };
153
+ declare class FloatingButton extends React$1.Component<Props> {
154
+ animation: Animated.Value;
155
+ open: boolean;
156
+ toggleMenu: () => void;
157
+ renderAction: (action: Action, index: number) => react_jsx_runtime.JSX.Element;
158
+ render(): react_jsx_runtime.JSX.Element;
159
+ }
160
+
131
161
  declare function MultiPickerItem({ label, selected, onPress, renderItemIcon, styles: customStyles, }: MultiPickerItemProps): react_jsx_runtime.JSX.Element;
132
162
 
133
163
  declare function MultiPickerGroup({ label, children, renderGroupIcon, }: MultiPickerGroupProps): react_jsx_runtime.JSX.Element;
@@ -136,4 +166,4 @@ declare const toggleValue: (arr: string[], value: string) => string[];
136
166
 
137
167
  declare const groupOptions: (options: Option[], config: Record<string, string[]>) => Group[];
138
168
 
139
- export { type Group, type MultiGroup, type MultiOption, MultiPickerGroup, type MultiPickerGroupProps, type MultiPickerGroupStyles, MultiPickerItem, type MultiPickerItemProps, type MultiPickerItemStyles, MultiPickerModal, type MultiPickerProps, type MultiPickerStyles, type Option, PickerModal, type PickerStyles, type Props, type Theme, groupOptions, toggleValue };
169
+ export { FloatingButton, type Group, type MultiGroup, type MultiOption, MultiPickerGroup, type MultiPickerGroupProps, type MultiPickerGroupStyles, MultiPickerItem, type MultiPickerItemProps, type MultiPickerItemStyles, MultiPickerModal, type MultiPickerProps, type MultiPickerStyles, type Option, PickerModal, type PickerStyles, type Props$1 as Props, type Theme, groupOptions, toggleValue };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React$1 from 'react';
3
- import { TextStyle, ViewStyle } from 'react-native';
3
+ import { TextStyle, ViewStyle, Animated } from 'react-native';
4
4
 
5
5
  type IconRenderer = (props: {
6
6
  name?: string;
@@ -37,7 +37,7 @@ type PickerStyles = {
37
37
  selectText?: TextStyle;
38
38
  error?: TextStyle;
39
39
  };
40
- type Props = {
40
+ type Props$1 = {
41
41
  labelStyle?: TextStyle;
42
42
  selectBoxStyle?: ViewStyle;
43
43
  selectTextStyle?: TextStyle;
@@ -57,7 +57,7 @@ type Props = {
57
57
  onClose: () => void;
58
58
  };
59
59
 
60
- declare function PickerModal({ visible, selectedValue, options, groups, styles, theme, renderTab, renderItem, renderContainer, onSelect, onClose, renderIcon, label, placeholder, error, labelStyle, selectBoxStyle, selectTextStyle, errorStyle, setVisible }: Props & {
60
+ declare function PickerModal({ visible, selectedValue, options, groups, styles, theme, renderTab, renderItem, renderContainer, onSelect, onClose, renderIcon, label, placeholder, error, labelStyle, selectBoxStyle, selectTextStyle, errorStyle, setVisible }: Props$1 & {
61
61
  label?: string;
62
62
  placeholder?: string;
63
63
  error?: string;
@@ -128,6 +128,36 @@ type MultiPickerProps = {
128
128
 
129
129
  declare function MultiPickerModal({ visible, setVisible, selectedValues, options, groups, onChange, label, placeholder, error, renderInputIcon, renderGroupIcon, renderItemIcon, styles, }: MultiPickerProps): react_jsx_runtime.JSX.Element;
130
130
 
131
+ type Action = {
132
+ icon: string;
133
+ onPress?: () => void;
134
+ navigateTo?: () => void;
135
+ color?: string;
136
+ iconColor?: string;
137
+ };
138
+ type FloatingButtonStyles = {
139
+ container?: ViewStyle;
140
+ mainButton?: ViewStyle;
141
+ secondaryButton?: ViewStyle;
142
+ };
143
+ type Props = {
144
+ actions: Action[];
145
+ mode?: "vertical" | "horizontal" | "circle";
146
+ radius?: number;
147
+ renderMainIcon?: IconRenderer;
148
+ renderItemIcon?: IconRenderer;
149
+ styles?: FloatingButtonStyles;
150
+ style?: ViewStyle;
151
+ mainIconName?: string;
152
+ };
153
+ declare class FloatingButton extends React$1.Component<Props> {
154
+ animation: Animated.Value;
155
+ open: boolean;
156
+ toggleMenu: () => void;
157
+ renderAction: (action: Action, index: number) => react_jsx_runtime.JSX.Element;
158
+ render(): react_jsx_runtime.JSX.Element;
159
+ }
160
+
131
161
  declare function MultiPickerItem({ label, selected, onPress, renderItemIcon, styles: customStyles, }: MultiPickerItemProps): react_jsx_runtime.JSX.Element;
132
162
 
133
163
  declare function MultiPickerGroup({ label, children, renderGroupIcon, }: MultiPickerGroupProps): react_jsx_runtime.JSX.Element;
@@ -136,4 +166,4 @@ declare const toggleValue: (arr: string[], value: string) => string[];
136
166
 
137
167
  declare const groupOptions: (options: Option[], config: Record<string, string[]>) => Group[];
138
168
 
139
- export { type Group, type MultiGroup, type MultiOption, MultiPickerGroup, type MultiPickerGroupProps, type MultiPickerGroupStyles, MultiPickerItem, type MultiPickerItemProps, type MultiPickerItemStyles, MultiPickerModal, type MultiPickerProps, type MultiPickerStyles, type Option, PickerModal, type PickerStyles, type Props, type Theme, groupOptions, toggleValue };
169
+ export { FloatingButton, type Group, type MultiGroup, type MultiOption, MultiPickerGroup, type MultiPickerGroupProps, type MultiPickerGroupStyles, MultiPickerItem, type MultiPickerItemProps, type MultiPickerItemStyles, MultiPickerModal, type MultiPickerProps, type MultiPickerStyles, type Option, PickerModal, type PickerStyles, type Props$1 as Props, type Theme, groupOptions, toggleValue };
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,11 +17,20 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
21
31
  var index_exports = {};
22
32
  __export(index_exports, {
33
+ FloatingButton: () => FloatingButton,
23
34
  MultiPickerGroup: () => MultiPickerGroup,
24
35
  MultiPickerItem: () => MultiPickerItem,
25
36
  MultiPickerModal: () => MultiPickerModal,
@@ -564,6 +575,151 @@ var defaultStyles3 = import_react_native4.StyleSheet.create({
564
575
  }
565
576
  });
566
577
 
578
+ // src/core/FloatingButton.tsx
579
+ var import_react4 = __toESM(require("react"));
580
+ var import_react_native5 = require("react-native");
581
+ var import_jsx_runtime5 = require("react/jsx-runtime");
582
+ var FloatingButton = class extends import_react4.default.Component {
583
+ animation = new import_react_native5.Animated.Value(0);
584
+ open = false;
585
+ toggleMenu = () => {
586
+ import_react_native5.Animated.spring(this.animation, {
587
+ toValue: this.open ? 0 : 1,
588
+ useNativeDriver: true,
589
+ damping: 12,
590
+ mass: 0.6,
591
+ stiffness: 180
592
+ }).start();
593
+ this.open = !this.open;
594
+ };
595
+ renderAction = (action, index) => {
596
+ const {
597
+ mode = "vertical",
598
+ radius = 100,
599
+ actions,
600
+ renderItemIcon,
601
+ styles: styles2
602
+ } = this.props;
603
+ let translateX = 0;
604
+ let translateY = 0;
605
+ if (mode === "vertical") {
606
+ translateY = -60 * (index + 1);
607
+ }
608
+ if (mode === "horizontal") {
609
+ translateX = -60 * (index + 1);
610
+ }
611
+ if (mode === "circle") {
612
+ const angleStep = Math.PI / 2;
613
+ const angle = index / (actions.length - 1 || 1) * angleStep;
614
+ translateX = -radius * Math.cos(angle);
615
+ translateY = -radius * Math.sin(angle);
616
+ }
617
+ const animStyle = {
618
+ transform: [
619
+ {
620
+ translateX: this.animation.interpolate({
621
+ inputRange: [0, 1],
622
+ outputRange: [0, translateX]
623
+ })
624
+ },
625
+ {
626
+ translateY: this.animation.interpolate({
627
+ inputRange: [0, 1],
628
+ outputRange: [0, translateY]
629
+ })
630
+ },
631
+ {
632
+ scale: this.animation.interpolate({
633
+ inputRange: [0, 0.5, 1],
634
+ outputRange: [0, 1.1, 1]
635
+ })
636
+ }
637
+ ],
638
+ opacity: this.animation
639
+ };
640
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
641
+ import_react_native5.TouchableWithoutFeedback,
642
+ {
643
+ onPress: () => {
644
+ this.toggleMenu();
645
+ action.onPress?.();
646
+ action.navigateTo?.();
647
+ },
648
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
649
+ import_react_native5.Animated.View,
650
+ {
651
+ style: [
652
+ defaultStyles4.secondary,
653
+ styles2?.secondaryButton,
654
+ { backgroundColor: action.color || "#F02A4B" },
655
+ animStyle
656
+ ],
657
+ children: renderItemIcon?.({
658
+ name: action.icon,
659
+ size: 20,
660
+ color: action.iconColor || "#FFF"
661
+ })
662
+ }
663
+ )
664
+ },
665
+ index
666
+ );
667
+ };
668
+ render() {
669
+ const { actions, renderMainIcon, styles: styles2, style, mainIconName } = this.props;
670
+ const rotation = {
671
+ transform: [
672
+ {
673
+ rotate: this.animation.interpolate({
674
+ inputRange: [0, 1],
675
+ outputRange: ["0deg", "45deg"]
676
+ })
677
+ }
678
+ ]
679
+ };
680
+ const mainIcon = mainIconName || "add";
681
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_native5.View, { style: [defaultStyles4.container, styles2?.container, style], children: [
682
+ actions.map(this.renderAction),
683
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.TouchableWithoutFeedback, { onPress: this.toggleMenu, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
684
+ import_react_native5.Animated.View,
685
+ {
686
+ style: [defaultStyles4.button, styles2?.mainButton, rotation],
687
+ children: renderMainIcon?.({
688
+ name: mainIcon,
689
+ size: 26,
690
+ color: "#FFF"
691
+ })
692
+ }
693
+ ) })
694
+ ] });
695
+ }
696
+ };
697
+ var defaultStyles4 = import_react_native5.StyleSheet.create({
698
+ container: {
699
+ position: "absolute",
700
+ bottom: 110,
701
+ right: 20,
702
+ alignItems: "center"
703
+ },
704
+ button: {
705
+ width: 60,
706
+ height: 60,
707
+ borderRadius: 30,
708
+ backgroundColor: "#F02A4B",
709
+ alignItems: "center",
710
+ justifyContent: "center"
711
+ },
712
+ secondary: {
713
+ position: "absolute",
714
+ width: 48,
715
+ height: 48,
716
+ borderRadius: 24,
717
+ backgroundColor: "#F02A4B",
718
+ alignItems: "center",
719
+ justifyContent: "center"
720
+ }
721
+ });
722
+
567
723
  // src/utils/groupOptions.ts
568
724
  var groupOptions = (options, config) => {
569
725
  return Object.entries(config).map(([label, values]) => ({
@@ -573,6 +729,7 @@ var groupOptions = (options, config) => {
573
729
  };
574
730
  // Annotate the CommonJS export names for ESM import in node:
575
731
  0 && (module.exports = {
732
+ FloatingButton,
576
733
  MultiPickerGroup,
577
734
  MultiPickerItem,
578
735
  MultiPickerModal,
package/dist/index.mjs CHANGED
@@ -553,6 +553,156 @@ var defaultStyles3 = StyleSheet4.create({
553
553
  }
554
554
  });
555
555
 
556
+ // src/core/FloatingButton.tsx
557
+ import React4 from "react";
558
+ import {
559
+ Animated as Animated2,
560
+ StyleSheet as StyleSheet5,
561
+ TouchableWithoutFeedback,
562
+ View as View5
563
+ } from "react-native";
564
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
565
+ var FloatingButton = class extends React4.Component {
566
+ animation = new Animated2.Value(0);
567
+ open = false;
568
+ toggleMenu = () => {
569
+ Animated2.spring(this.animation, {
570
+ toValue: this.open ? 0 : 1,
571
+ useNativeDriver: true,
572
+ damping: 12,
573
+ mass: 0.6,
574
+ stiffness: 180
575
+ }).start();
576
+ this.open = !this.open;
577
+ };
578
+ renderAction = (action, index) => {
579
+ const {
580
+ mode = "vertical",
581
+ radius = 100,
582
+ actions,
583
+ renderItemIcon,
584
+ styles: styles2
585
+ } = this.props;
586
+ let translateX = 0;
587
+ let translateY = 0;
588
+ if (mode === "vertical") {
589
+ translateY = -60 * (index + 1);
590
+ }
591
+ if (mode === "horizontal") {
592
+ translateX = -60 * (index + 1);
593
+ }
594
+ if (mode === "circle") {
595
+ const angleStep = Math.PI / 2;
596
+ const angle = index / (actions.length - 1 || 1) * angleStep;
597
+ translateX = -radius * Math.cos(angle);
598
+ translateY = -radius * Math.sin(angle);
599
+ }
600
+ const animStyle = {
601
+ transform: [
602
+ {
603
+ translateX: this.animation.interpolate({
604
+ inputRange: [0, 1],
605
+ outputRange: [0, translateX]
606
+ })
607
+ },
608
+ {
609
+ translateY: this.animation.interpolate({
610
+ inputRange: [0, 1],
611
+ outputRange: [0, translateY]
612
+ })
613
+ },
614
+ {
615
+ scale: this.animation.interpolate({
616
+ inputRange: [0, 0.5, 1],
617
+ outputRange: [0, 1.1, 1]
618
+ })
619
+ }
620
+ ],
621
+ opacity: this.animation
622
+ };
623
+ return /* @__PURE__ */ jsx5(
624
+ TouchableWithoutFeedback,
625
+ {
626
+ onPress: () => {
627
+ this.toggleMenu();
628
+ action.onPress?.();
629
+ action.navigateTo?.();
630
+ },
631
+ children: /* @__PURE__ */ jsx5(
632
+ Animated2.View,
633
+ {
634
+ style: [
635
+ defaultStyles4.secondary,
636
+ styles2?.secondaryButton,
637
+ { backgroundColor: action.color || "#F02A4B" },
638
+ animStyle
639
+ ],
640
+ children: renderItemIcon?.({
641
+ name: action.icon,
642
+ size: 20,
643
+ color: action.iconColor || "#FFF"
644
+ })
645
+ }
646
+ )
647
+ },
648
+ index
649
+ );
650
+ };
651
+ render() {
652
+ const { actions, renderMainIcon, styles: styles2, style, mainIconName } = this.props;
653
+ const rotation = {
654
+ transform: [
655
+ {
656
+ rotate: this.animation.interpolate({
657
+ inputRange: [0, 1],
658
+ outputRange: ["0deg", "45deg"]
659
+ })
660
+ }
661
+ ]
662
+ };
663
+ const mainIcon = mainIconName || "add";
664
+ return /* @__PURE__ */ jsxs5(View5, { style: [defaultStyles4.container, styles2?.container, style], children: [
665
+ actions.map(this.renderAction),
666
+ /* @__PURE__ */ jsx5(TouchableWithoutFeedback, { onPress: this.toggleMenu, children: /* @__PURE__ */ jsx5(
667
+ Animated2.View,
668
+ {
669
+ style: [defaultStyles4.button, styles2?.mainButton, rotation],
670
+ children: renderMainIcon?.({
671
+ name: mainIcon,
672
+ size: 26,
673
+ color: "#FFF"
674
+ })
675
+ }
676
+ ) })
677
+ ] });
678
+ }
679
+ };
680
+ var defaultStyles4 = StyleSheet5.create({
681
+ container: {
682
+ position: "absolute",
683
+ bottom: 110,
684
+ right: 20,
685
+ alignItems: "center"
686
+ },
687
+ button: {
688
+ width: 60,
689
+ height: 60,
690
+ borderRadius: 30,
691
+ backgroundColor: "#F02A4B",
692
+ alignItems: "center",
693
+ justifyContent: "center"
694
+ },
695
+ secondary: {
696
+ position: "absolute",
697
+ width: 48,
698
+ height: 48,
699
+ borderRadius: 24,
700
+ backgroundColor: "#F02A4B",
701
+ alignItems: "center",
702
+ justifyContent: "center"
703
+ }
704
+ });
705
+
556
706
  // src/utils/groupOptions.ts
557
707
  var groupOptions = (options, config) => {
558
708
  return Object.entries(config).map(([label, values]) => ({
@@ -561,6 +711,7 @@ var groupOptions = (options, config) => {
561
711
  })).filter((g) => g.data.length > 0);
562
712
  };
563
713
  export {
714
+ FloatingButton,
564
715
  MultiPickerGroup,
565
716
  MultiPickerItem,
566
717
  MultiPickerModal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaushverse/pickify",
3
- "version": "1.1.1",
3
+ "version": "1.1.4",
4
4
  "description": "A fully customizable React Native picker with search, multi-select, grouping, and async support.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",