@kaushverse/pickify 1.1.1 → 1.1.3

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,33 @@ 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
+ };
135
+ type FloatingButtonStyles = {
136
+ container?: ViewStyle;
137
+ mainButton?: ViewStyle;
138
+ secondaryButton?: ViewStyle;
139
+ mainIcon?: TextStyle;
140
+ secondaryIcon?: TextStyle;
141
+ };
142
+ type Props = {
143
+ actions: Action[];
144
+ mode?: "vertical" | "horizontal" | "circle";
145
+ radius?: number;
146
+ renderIcon?: IconRenderer;
147
+ styles?: FloatingButtonStyles;
148
+ style?: ViewStyle;
149
+ };
150
+ declare class FloatingButton extends React$1.Component<Props> {
151
+ animation: Animated.Value;
152
+ open: boolean;
153
+ toggleMenu: () => void;
154
+ renderAction: (action: Action, index: number) => react_jsx_runtime.JSX.Element;
155
+ render(): react_jsx_runtime.JSX.Element;
156
+ }
157
+
131
158
  declare function MultiPickerItem({ label, selected, onPress, renderItemIcon, styles: customStyles, }: MultiPickerItemProps): react_jsx_runtime.JSX.Element;
132
159
 
133
160
  declare function MultiPickerGroup({ label, children, renderGroupIcon, }: MultiPickerGroupProps): react_jsx_runtime.JSX.Element;
@@ -136,4 +163,4 @@ declare const toggleValue: (arr: string[], value: string) => string[];
136
163
 
137
164
  declare const groupOptions: (options: Option[], config: Record<string, string[]>) => Group[];
138
165
 
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 };
166
+ 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,33 @@ 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
+ };
135
+ type FloatingButtonStyles = {
136
+ container?: ViewStyle;
137
+ mainButton?: ViewStyle;
138
+ secondaryButton?: ViewStyle;
139
+ mainIcon?: TextStyle;
140
+ secondaryIcon?: TextStyle;
141
+ };
142
+ type Props = {
143
+ actions: Action[];
144
+ mode?: "vertical" | "horizontal" | "circle";
145
+ radius?: number;
146
+ renderIcon?: IconRenderer;
147
+ styles?: FloatingButtonStyles;
148
+ style?: ViewStyle;
149
+ };
150
+ declare class FloatingButton extends React$1.Component<Props> {
151
+ animation: Animated.Value;
152
+ open: boolean;
153
+ toggleMenu: () => void;
154
+ renderAction: (action: Action, index: number) => react_jsx_runtime.JSX.Element;
155
+ render(): react_jsx_runtime.JSX.Element;
156
+ }
157
+
131
158
  declare function MultiPickerItem({ label, selected, onPress, renderItemIcon, styles: customStyles, }: MultiPickerItemProps): react_jsx_runtime.JSX.Element;
132
159
 
133
160
  declare function MultiPickerGroup({ label, children, renderGroupIcon, }: MultiPickerGroupProps): react_jsx_runtime.JSX.Element;
@@ -136,4 +163,4 @@ declare const toggleValue: (arr: string[], value: string) => string[];
136
163
 
137
164
  declare const groupOptions: (options: Option[], config: Record<string, string[]>) => Group[];
138
165
 
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 };
166
+ 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,149 @@ 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
+ renderIcon,
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 angle = index / actions.length * Math.PI;
613
+ translateX = radius * Math.cos(angle);
614
+ translateY = -radius * Math.sin(angle);
615
+ }
616
+ const animStyle = {
617
+ transform: [
618
+ {
619
+ translateX: this.animation.interpolate({
620
+ inputRange: [0, 1],
621
+ outputRange: [0, translateX]
622
+ })
623
+ },
624
+ {
625
+ translateY: this.animation.interpolate({
626
+ inputRange: [0, 1],
627
+ outputRange: [0, translateY]
628
+ })
629
+ },
630
+ {
631
+ scale: this.animation.interpolate({
632
+ inputRange: [0, 0.5, 1],
633
+ outputRange: [0, 1.1, 1]
634
+ })
635
+ }
636
+ ],
637
+ opacity: this.animation
638
+ };
639
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
640
+ import_react_native5.TouchableWithoutFeedback,
641
+ {
642
+ onPress: () => {
643
+ this.toggleMenu();
644
+ action.onPress();
645
+ },
646
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
647
+ import_react_native5.Animated.View,
648
+ {
649
+ style: [defaultStyles4.secondary, styles2?.secondaryButton, animStyle],
650
+ children: renderIcon?.({
651
+ name: action.icon,
652
+ size: 20,
653
+ color: "#FFF"
654
+ })
655
+ }
656
+ )
657
+ },
658
+ index
659
+ );
660
+ };
661
+ render() {
662
+ const { actions, renderIcon, styles: styles2, style } = this.props;
663
+ const rotation = {
664
+ transform: [
665
+ {
666
+ rotate: this.animation.interpolate({
667
+ inputRange: [0, 1],
668
+ outputRange: ["0deg", "45deg"]
669
+ })
670
+ }
671
+ ]
672
+ };
673
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
674
+ import_react_native5.View,
675
+ {
676
+ style: [defaultStyles4.container, styles2?.container, this.props.style],
677
+ children: [
678
+ actions.map(this.renderAction),
679
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.TouchableWithoutFeedback, { onPress: this.toggleMenu, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
680
+ import_react_native5.Animated.View,
681
+ {
682
+ style: [defaultStyles4.button, styles2?.mainButton, rotation],
683
+ children: renderIcon?.({
684
+ name: "plus",
685
+ size: 26,
686
+ color: "#FFF"
687
+ })
688
+ }
689
+ ) })
690
+ ]
691
+ }
692
+ );
693
+ }
694
+ };
695
+ var defaultStyles4 = import_react_native5.StyleSheet.create({
696
+ container: {
697
+ position: "absolute",
698
+ bottom: 110,
699
+ right: 20,
700
+ alignItems: "center"
701
+ },
702
+ button: {
703
+ width: 60,
704
+ height: 60,
705
+ borderRadius: 30,
706
+ backgroundColor: "#F02A4B",
707
+ alignItems: "center",
708
+ justifyContent: "center"
709
+ },
710
+ secondary: {
711
+ position: "absolute",
712
+ width: 48,
713
+ height: 48,
714
+ borderRadius: 24,
715
+ backgroundColor: "#F02A4B",
716
+ alignItems: "center",
717
+ justifyContent: "center"
718
+ }
719
+ });
720
+
567
721
  // src/utils/groupOptions.ts
568
722
  var groupOptions = (options, config) => {
569
723
  return Object.entries(config).map(([label, values]) => ({
@@ -573,6 +727,7 @@ var groupOptions = (options, config) => {
573
727
  };
574
728
  // Annotate the CommonJS export names for ESM import in node:
575
729
  0 && (module.exports = {
730
+ FloatingButton,
576
731
  MultiPickerGroup,
577
732
  MultiPickerItem,
578
733
  MultiPickerModal,
package/dist/index.mjs CHANGED
@@ -553,6 +553,154 @@ 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
+ renderIcon,
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 angle = index / actions.length * Math.PI;
596
+ translateX = radius * Math.cos(angle);
597
+ translateY = -radius * Math.sin(angle);
598
+ }
599
+ const animStyle = {
600
+ transform: [
601
+ {
602
+ translateX: this.animation.interpolate({
603
+ inputRange: [0, 1],
604
+ outputRange: [0, translateX]
605
+ })
606
+ },
607
+ {
608
+ translateY: this.animation.interpolate({
609
+ inputRange: [0, 1],
610
+ outputRange: [0, translateY]
611
+ })
612
+ },
613
+ {
614
+ scale: this.animation.interpolate({
615
+ inputRange: [0, 0.5, 1],
616
+ outputRange: [0, 1.1, 1]
617
+ })
618
+ }
619
+ ],
620
+ opacity: this.animation
621
+ };
622
+ return /* @__PURE__ */ jsx5(
623
+ TouchableWithoutFeedback,
624
+ {
625
+ onPress: () => {
626
+ this.toggleMenu();
627
+ action.onPress();
628
+ },
629
+ children: /* @__PURE__ */ jsx5(
630
+ Animated2.View,
631
+ {
632
+ style: [defaultStyles4.secondary, styles2?.secondaryButton, animStyle],
633
+ children: renderIcon?.({
634
+ name: action.icon,
635
+ size: 20,
636
+ color: "#FFF"
637
+ })
638
+ }
639
+ )
640
+ },
641
+ index
642
+ );
643
+ };
644
+ render() {
645
+ const { actions, renderIcon, styles: styles2, style } = this.props;
646
+ const rotation = {
647
+ transform: [
648
+ {
649
+ rotate: this.animation.interpolate({
650
+ inputRange: [0, 1],
651
+ outputRange: ["0deg", "45deg"]
652
+ })
653
+ }
654
+ ]
655
+ };
656
+ return /* @__PURE__ */ jsxs5(
657
+ View5,
658
+ {
659
+ style: [defaultStyles4.container, styles2?.container, this.props.style],
660
+ children: [
661
+ actions.map(this.renderAction),
662
+ /* @__PURE__ */ jsx5(TouchableWithoutFeedback, { onPress: this.toggleMenu, children: /* @__PURE__ */ jsx5(
663
+ Animated2.View,
664
+ {
665
+ style: [defaultStyles4.button, styles2?.mainButton, rotation],
666
+ children: renderIcon?.({
667
+ name: "plus",
668
+ size: 26,
669
+ color: "#FFF"
670
+ })
671
+ }
672
+ ) })
673
+ ]
674
+ }
675
+ );
676
+ }
677
+ };
678
+ var defaultStyles4 = StyleSheet5.create({
679
+ container: {
680
+ position: "absolute",
681
+ bottom: 110,
682
+ right: 20,
683
+ alignItems: "center"
684
+ },
685
+ button: {
686
+ width: 60,
687
+ height: 60,
688
+ borderRadius: 30,
689
+ backgroundColor: "#F02A4B",
690
+ alignItems: "center",
691
+ justifyContent: "center"
692
+ },
693
+ secondary: {
694
+ position: "absolute",
695
+ width: 48,
696
+ height: 48,
697
+ borderRadius: 24,
698
+ backgroundColor: "#F02A4B",
699
+ alignItems: "center",
700
+ justifyContent: "center"
701
+ }
702
+ });
703
+
556
704
  // src/utils/groupOptions.ts
557
705
  var groupOptions = (options, config) => {
558
706
  return Object.entries(config).map(([label, values]) => ({
@@ -561,6 +709,7 @@ var groupOptions = (options, config) => {
561
709
  })).filter((g) => g.data.length > 0);
562
710
  };
563
711
  export {
712
+ FloatingButton,
564
713
  MultiPickerGroup,
565
714
  MultiPickerItem,
566
715
  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.3",
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",