@kaushverse/pickify 1.1.5 → 1.1.6

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.js CHANGED
@@ -291,17 +291,25 @@ function MultiPickerGroup({
291
291
  renderGroupIcon,
292
292
  defaultOpen = false
293
293
  }) {
294
- const [open, setOpen] = (0, import_react2.useState)(defaultOpen);
294
+ const [open, setOpen] = (0, import_react2.useState)(false);
295
295
  const [contentHeight, setContentHeight] = (0, import_react2.useState)(0);
296
296
  const animatedHeight = (0, import_react2.useRef)(new import_react_native2.Animated.Value(0)).current;
297
+ (0, import_react2.useEffect)(() => {
298
+ if (defaultOpen && contentHeight > 0) {
299
+ animatedHeight.setValue(contentHeight);
300
+ setOpen(true);
301
+ }
302
+ }, [contentHeight, defaultOpen]);
297
303
  const toggle = () => {
304
+ if (contentHeight === 0) return;
298
305
  const toValue = open ? 0 : contentHeight;
299
306
  import_react_native2.Animated.timing(animatedHeight, {
300
307
  toValue,
301
308
  duration: 250,
302
309
  useNativeDriver: false
303
- }).start();
304
- setOpen(!open);
310
+ }).start(() => {
311
+ setOpen(!open);
312
+ });
305
313
  };
306
314
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.View, { style: styles.group, children: [
307
315
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.TouchableOpacity, { style: styles.header, onPress: toggle, children: [
@@ -316,8 +324,12 @@ function MultiPickerGroup({
316
324
  import_react_native2.View,
317
325
  {
318
326
  style: styles.hidden,
327
+ pointerEvents: "none",
319
328
  onLayout: (e) => {
320
- setContentHeight(e.nativeEvent.layout.height);
329
+ const height = e.nativeEvent.layout.height;
330
+ if (height !== contentHeight) {
331
+ setContentHeight(height);
332
+ }
321
333
  },
322
334
  children
323
335
  }
@@ -354,7 +366,9 @@ var styles = import_react_native2.StyleSheet.create({
354
366
  hidden: {
355
367
  position: "absolute",
356
368
  opacity: 0,
357
- zIndex: -1
369
+ zIndex: -1,
370
+ left: 0,
371
+ right: 0
358
372
  }
359
373
  });
360
374
 
@@ -596,8 +610,8 @@ var FloatingButton = class extends import_react4.default.Component {
596
610
  };
597
611
  renderAction = (action, index) => {
598
612
  const {
599
- mode = "vertical",
600
- radius = 100,
613
+ mode = "circle",
614
+ radius = 90,
601
615
  actions,
602
616
  renderItemIcon,
603
617
  styles: styles2
@@ -605,18 +619,17 @@ var FloatingButton = class extends import_react4.default.Component {
605
619
  let translateX = 0;
606
620
  let translateY = 0;
607
621
  if (mode === "vertical") {
608
- translateY = -60 * (index + 1);
622
+ translateY = -55 * (index + 1);
609
623
  }
610
624
  if (mode === "horizontal") {
611
- translateX = -60 * (index + 1);
625
+ translateX = -55 * (index + 1);
612
626
  }
613
627
  if (mode === "circle") {
614
- const angleStep = Math.PI / 2;
615
- const angle = index / (actions.length - 1 || 1) * angleStep;
616
- const adjustedRadiusX = radius * 0.7;
617
- const adjustedRadiusY = radius;
618
- translateX = -adjustedRadiusX * Math.cos(angle);
619
- translateY = -adjustedRadiusY * Math.sin(angle);
628
+ const startAngle = Math.PI * 1.1;
629
+ const endAngle = Math.PI * 1.9;
630
+ const angle = startAngle + index / (actions.length - 1 || 1) * (endAngle - startAngle);
631
+ translateX = radius * Math.cos(angle);
632
+ translateY = radius * Math.sin(angle);
620
633
  }
621
634
  const animStyle = {
622
635
  transform: [
@@ -701,7 +714,7 @@ var FloatingButton = class extends import_react4.default.Component {
701
714
  var defaultStyles4 = import_react_native5.StyleSheet.create({
702
715
  container: {
703
716
  position: "absolute",
704
- bottom: 110,
717
+ bottom: 100,
705
718
  right: 20,
706
719
  alignItems: "center"
707
720
  },
@@ -715,9 +728,9 @@ var defaultStyles4 = import_react_native5.StyleSheet.create({
715
728
  },
716
729
  secondary: {
717
730
  position: "absolute",
718
- width: 48,
719
- height: 48,
720
- borderRadius: 24,
731
+ width: 46,
732
+ height: 46,
733
+ borderRadius: 23,
721
734
  backgroundColor: "#F02A4B",
722
735
  alignItems: "center",
723
736
  justifyContent: "center"
package/dist/index.mjs CHANGED
@@ -254,7 +254,7 @@ var toggleValue = (arr, value) => {
254
254
  };
255
255
 
256
256
  // src/components/MultiPickerGroup.tsx
257
- import { useRef, useState as useState2 } from "react";
257
+ import { useRef, useState as useState2, useEffect as useEffect2 } from "react";
258
258
  import {
259
259
  View as View2,
260
260
  Text as Text2,
@@ -269,17 +269,25 @@ function MultiPickerGroup({
269
269
  renderGroupIcon,
270
270
  defaultOpen = false
271
271
  }) {
272
- const [open, setOpen] = useState2(defaultOpen);
272
+ const [open, setOpen] = useState2(false);
273
273
  const [contentHeight, setContentHeight] = useState2(0);
274
274
  const animatedHeight = useRef(new Animated.Value(0)).current;
275
+ useEffect2(() => {
276
+ if (defaultOpen && contentHeight > 0) {
277
+ animatedHeight.setValue(contentHeight);
278
+ setOpen(true);
279
+ }
280
+ }, [contentHeight, defaultOpen]);
275
281
  const toggle = () => {
282
+ if (contentHeight === 0) return;
276
283
  const toValue = open ? 0 : contentHeight;
277
284
  Animated.timing(animatedHeight, {
278
285
  toValue,
279
286
  duration: 250,
280
287
  useNativeDriver: false
281
- }).start();
282
- setOpen(!open);
288
+ }).start(() => {
289
+ setOpen(!open);
290
+ });
283
291
  };
284
292
  return /* @__PURE__ */ jsxs2(View2, { style: styles.group, children: [
285
293
  /* @__PURE__ */ jsxs2(TouchableOpacity2, { style: styles.header, onPress: toggle, children: [
@@ -294,8 +302,12 @@ function MultiPickerGroup({
294
302
  View2,
295
303
  {
296
304
  style: styles.hidden,
305
+ pointerEvents: "none",
297
306
  onLayout: (e) => {
298
- setContentHeight(e.nativeEvent.layout.height);
307
+ const height = e.nativeEvent.layout.height;
308
+ if (height !== contentHeight) {
309
+ setContentHeight(height);
310
+ }
299
311
  },
300
312
  children
301
313
  }
@@ -332,7 +344,9 @@ var styles = StyleSheet2.create({
332
344
  hidden: {
333
345
  position: "absolute",
334
346
  opacity: 0,
335
- zIndex: -1
347
+ zIndex: -1,
348
+ left: 0,
349
+ right: 0
336
350
  }
337
351
  });
338
352
 
@@ -579,8 +593,8 @@ var FloatingButton = class extends React4.Component {
579
593
  };
580
594
  renderAction = (action, index) => {
581
595
  const {
582
- mode = "vertical",
583
- radius = 100,
596
+ mode = "circle",
597
+ radius = 90,
584
598
  actions,
585
599
  renderItemIcon,
586
600
  styles: styles2
@@ -588,18 +602,17 @@ var FloatingButton = class extends React4.Component {
588
602
  let translateX = 0;
589
603
  let translateY = 0;
590
604
  if (mode === "vertical") {
591
- translateY = -60 * (index + 1);
605
+ translateY = -55 * (index + 1);
592
606
  }
593
607
  if (mode === "horizontal") {
594
- translateX = -60 * (index + 1);
608
+ translateX = -55 * (index + 1);
595
609
  }
596
610
  if (mode === "circle") {
597
- const angleStep = Math.PI / 2;
598
- const angle = index / (actions.length - 1 || 1) * angleStep;
599
- const adjustedRadiusX = radius * 0.7;
600
- const adjustedRadiusY = radius;
601
- translateX = -adjustedRadiusX * Math.cos(angle);
602
- translateY = -adjustedRadiusY * Math.sin(angle);
611
+ const startAngle = Math.PI * 1.1;
612
+ const endAngle = Math.PI * 1.9;
613
+ const angle = startAngle + index / (actions.length - 1 || 1) * (endAngle - startAngle);
614
+ translateX = radius * Math.cos(angle);
615
+ translateY = radius * Math.sin(angle);
603
616
  }
604
617
  const animStyle = {
605
618
  transform: [
@@ -684,7 +697,7 @@ var FloatingButton = class extends React4.Component {
684
697
  var defaultStyles4 = StyleSheet5.create({
685
698
  container: {
686
699
  position: "absolute",
687
- bottom: 110,
700
+ bottom: 100,
688
701
  right: 20,
689
702
  alignItems: "center"
690
703
  },
@@ -698,9 +711,9 @@ var defaultStyles4 = StyleSheet5.create({
698
711
  },
699
712
  secondary: {
700
713
  position: "absolute",
701
- width: 48,
702
- height: 48,
703
- borderRadius: 24,
714
+ width: 46,
715
+ height: 46,
716
+ borderRadius: 23,
704
717
  backgroundColor: "#F02A4B",
705
718
  alignItems: "center",
706
719
  justifyContent: "center"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaushverse/pickify",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
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",