@kaushverse/pickify 1.1.4 → 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.d.mts CHANGED
@@ -97,6 +97,7 @@ type MultiPickerGroupProps = {
97
97
  children: React.ReactNode;
98
98
  renderGroupIcon?: IconRenderer;
99
99
  styles?: MultiPickerGroupStyles;
100
+ defaultOpen: boolean;
100
101
  };
101
102
  type MultiPickerStyles = {
102
103
  overlay?: ViewStyle;
@@ -160,7 +161,7 @@ declare class FloatingButton extends React$1.Component<Props> {
160
161
 
161
162
  declare function MultiPickerItem({ label, selected, onPress, renderItemIcon, styles: customStyles, }: MultiPickerItemProps): react_jsx_runtime.JSX.Element;
162
163
 
163
- declare function MultiPickerGroup({ label, children, renderGroupIcon, }: MultiPickerGroupProps): react_jsx_runtime.JSX.Element;
164
+ declare function MultiPickerGroup({ label, children, renderGroupIcon, defaultOpen, }: MultiPickerGroupProps): react_jsx_runtime.JSX.Element;
164
165
 
165
166
  declare const toggleValue: (arr: string[], value: string) => string[];
166
167
 
package/dist/index.d.ts CHANGED
@@ -97,6 +97,7 @@ type MultiPickerGroupProps = {
97
97
  children: React.ReactNode;
98
98
  renderGroupIcon?: IconRenderer;
99
99
  styles?: MultiPickerGroupStyles;
100
+ defaultOpen: boolean;
100
101
  };
101
102
  type MultiPickerStyles = {
102
103
  overlay?: ViewStyle;
@@ -160,7 +161,7 @@ declare class FloatingButton extends React$1.Component<Props> {
160
161
 
161
162
  declare function MultiPickerItem({ label, selected, onPress, renderItemIcon, styles: customStyles, }: MultiPickerItemProps): react_jsx_runtime.JSX.Element;
162
163
 
163
- declare function MultiPickerGroup({ label, children, renderGroupIcon, }: MultiPickerGroupProps): react_jsx_runtime.JSX.Element;
164
+ declare function MultiPickerGroup({ label, children, renderGroupIcon, defaultOpen, }: MultiPickerGroupProps): react_jsx_runtime.JSX.Element;
164
165
 
165
166
  declare const toggleValue: (arr: string[], value: string) => string[];
166
167
 
package/dist/index.js CHANGED
@@ -288,19 +288,28 @@ var import_jsx_runtime2 = require("react/jsx-runtime");
288
288
  function MultiPickerGroup({
289
289
  label,
290
290
  children,
291
- renderGroupIcon
291
+ renderGroupIcon,
292
+ defaultOpen = false
292
293
  }) {
293
- const [open, setOpen] = (0, import_react2.useState)(true);
294
+ const [open, setOpen] = (0, import_react2.useState)(false);
294
295
  const [contentHeight, setContentHeight] = (0, import_react2.useState)(0);
295
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]);
296
303
  const toggle = () => {
304
+ if (contentHeight === 0) return;
297
305
  const toValue = open ? 0 : contentHeight;
298
306
  import_react_native2.Animated.timing(animatedHeight, {
299
307
  toValue,
300
308
  duration: 250,
301
309
  useNativeDriver: false
302
- }).start();
303
- setOpen(!open);
310
+ }).start(() => {
311
+ setOpen(!open);
312
+ });
304
313
  };
305
314
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.View, { style: styles.group, children: [
306
315
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.TouchableOpacity, { style: styles.header, onPress: toggle, children: [
@@ -315,8 +324,12 @@ function MultiPickerGroup({
315
324
  import_react_native2.View,
316
325
  {
317
326
  style: styles.hidden,
327
+ pointerEvents: "none",
318
328
  onLayout: (e) => {
319
- setContentHeight(e.nativeEvent.layout.height);
329
+ const height = e.nativeEvent.layout.height;
330
+ if (height !== contentHeight) {
331
+ setContentHeight(height);
332
+ }
320
333
  },
321
334
  children
322
335
  }
@@ -353,7 +366,9 @@ var styles = import_react_native2.StyleSheet.create({
353
366
  hidden: {
354
367
  position: "absolute",
355
368
  opacity: 0,
356
- zIndex: -1
369
+ zIndex: -1,
370
+ left: 0,
371
+ right: 0
357
372
  }
358
373
  });
359
374
 
@@ -464,11 +479,12 @@ function MultiPickerModal({
464
479
  };
465
480
  const renderList = () => {
466
481
  if (groups.length > 0) {
467
- return groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
482
+ return groups.map((group, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
468
483
  MultiPickerGroup,
469
484
  {
470
485
  label: group.label,
471
486
  renderGroupIcon,
487
+ defaultOpen: index === 0,
472
488
  children: group.data.map((item) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
473
489
  MultiPickerItem,
474
490
  {
@@ -594,8 +610,8 @@ var FloatingButton = class extends import_react4.default.Component {
594
610
  };
595
611
  renderAction = (action, index) => {
596
612
  const {
597
- mode = "vertical",
598
- radius = 100,
613
+ mode = "circle",
614
+ radius = 90,
599
615
  actions,
600
616
  renderItemIcon,
601
617
  styles: styles2
@@ -603,16 +619,17 @@ var FloatingButton = class extends import_react4.default.Component {
603
619
  let translateX = 0;
604
620
  let translateY = 0;
605
621
  if (mode === "vertical") {
606
- translateY = -60 * (index + 1);
622
+ translateY = -55 * (index + 1);
607
623
  }
608
624
  if (mode === "horizontal") {
609
- translateX = -60 * (index + 1);
625
+ translateX = -55 * (index + 1);
610
626
  }
611
627
  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);
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);
616
633
  }
617
634
  const animStyle = {
618
635
  transform: [
@@ -697,7 +714,7 @@ var FloatingButton = class extends import_react4.default.Component {
697
714
  var defaultStyles4 = import_react_native5.StyleSheet.create({
698
715
  container: {
699
716
  position: "absolute",
700
- bottom: 110,
717
+ bottom: 100,
701
718
  right: 20,
702
719
  alignItems: "center"
703
720
  },
@@ -711,9 +728,9 @@ var defaultStyles4 = import_react_native5.StyleSheet.create({
711
728
  },
712
729
  secondary: {
713
730
  position: "absolute",
714
- width: 48,
715
- height: 48,
716
- borderRadius: 24,
731
+ width: 46,
732
+ height: 46,
733
+ borderRadius: 23,
717
734
  backgroundColor: "#F02A4B",
718
735
  alignItems: "center",
719
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,
@@ -266,19 +266,28 @@ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
266
266
  function MultiPickerGroup({
267
267
  label,
268
268
  children,
269
- renderGroupIcon
269
+ renderGroupIcon,
270
+ defaultOpen = false
270
271
  }) {
271
- const [open, setOpen] = useState2(true);
272
+ const [open, setOpen] = useState2(false);
272
273
  const [contentHeight, setContentHeight] = useState2(0);
273
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]);
274
281
  const toggle = () => {
282
+ if (contentHeight === 0) return;
275
283
  const toValue = open ? 0 : contentHeight;
276
284
  Animated.timing(animatedHeight, {
277
285
  toValue,
278
286
  duration: 250,
279
287
  useNativeDriver: false
280
- }).start();
281
- setOpen(!open);
288
+ }).start(() => {
289
+ setOpen(!open);
290
+ });
282
291
  };
283
292
  return /* @__PURE__ */ jsxs2(View2, { style: styles.group, children: [
284
293
  /* @__PURE__ */ jsxs2(TouchableOpacity2, { style: styles.header, onPress: toggle, children: [
@@ -293,8 +302,12 @@ function MultiPickerGroup({
293
302
  View2,
294
303
  {
295
304
  style: styles.hidden,
305
+ pointerEvents: "none",
296
306
  onLayout: (e) => {
297
- setContentHeight(e.nativeEvent.layout.height);
307
+ const height = e.nativeEvent.layout.height;
308
+ if (height !== contentHeight) {
309
+ setContentHeight(height);
310
+ }
298
311
  },
299
312
  children
300
313
  }
@@ -331,7 +344,9 @@ var styles = StyleSheet2.create({
331
344
  hidden: {
332
345
  position: "absolute",
333
346
  opacity: 0,
334
- zIndex: -1
347
+ zIndex: -1,
348
+ left: 0,
349
+ right: 0
335
350
  }
336
351
  });
337
352
 
@@ -442,11 +457,12 @@ function MultiPickerModal({
442
457
  };
443
458
  const renderList = () => {
444
459
  if (groups.length > 0) {
445
- return groups.map((group) => /* @__PURE__ */ jsx4(
460
+ return groups.map((group, index) => /* @__PURE__ */ jsx4(
446
461
  MultiPickerGroup,
447
462
  {
448
463
  label: group.label,
449
464
  renderGroupIcon,
465
+ defaultOpen: index === 0,
450
466
  children: group.data.map((item) => /* @__PURE__ */ jsx4(
451
467
  MultiPickerItem,
452
468
  {
@@ -577,8 +593,8 @@ var FloatingButton = class extends React4.Component {
577
593
  };
578
594
  renderAction = (action, index) => {
579
595
  const {
580
- mode = "vertical",
581
- radius = 100,
596
+ mode = "circle",
597
+ radius = 90,
582
598
  actions,
583
599
  renderItemIcon,
584
600
  styles: styles2
@@ -586,16 +602,17 @@ var FloatingButton = class extends React4.Component {
586
602
  let translateX = 0;
587
603
  let translateY = 0;
588
604
  if (mode === "vertical") {
589
- translateY = -60 * (index + 1);
605
+ translateY = -55 * (index + 1);
590
606
  }
591
607
  if (mode === "horizontal") {
592
- translateX = -60 * (index + 1);
608
+ translateX = -55 * (index + 1);
593
609
  }
594
610
  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);
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);
599
616
  }
600
617
  const animStyle = {
601
618
  transform: [
@@ -680,7 +697,7 @@ var FloatingButton = class extends React4.Component {
680
697
  var defaultStyles4 = StyleSheet5.create({
681
698
  container: {
682
699
  position: "absolute",
683
- bottom: 110,
700
+ bottom: 100,
684
701
  right: 20,
685
702
  alignItems: "center"
686
703
  },
@@ -694,9 +711,9 @@ var defaultStyles4 = StyleSheet5.create({
694
711
  },
695
712
  secondary: {
696
713
  position: "absolute",
697
- width: 48,
698
- height: 48,
699
- borderRadius: 24,
714
+ width: 46,
715
+ height: 46,
716
+ borderRadius: 23,
700
717
  backgroundColor: "#F02A4B",
701
718
  alignItems: "center",
702
719
  justifyContent: "center"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaushverse/pickify",
3
- "version": "1.1.4",
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",