@kaushverse/pickify 1.0.10 → 1.0.12

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
@@ -3,9 +3,9 @@ import React$1 from 'react';
3
3
  import { TextStyle, ViewStyle } from 'react-native';
4
4
 
5
5
  type IconRenderer = (props: {
6
- name: string;
7
- size: number;
8
- color: string;
6
+ name?: string;
7
+ size?: number;
8
+ color?: string;
9
9
  }) => React.ReactNode;
10
10
 
11
11
  type Option = {
package/dist/index.d.ts CHANGED
@@ -3,9 +3,9 @@ import React$1 from 'react';
3
3
  import { TextStyle, ViewStyle } from 'react-native';
4
4
 
5
5
  type IconRenderer = (props: {
6
- name: string;
7
- size: number;
8
- color: string;
6
+ name?: string;
7
+ size?: number;
8
+ color?: string;
9
9
  }) => React.ReactNode;
10
10
 
11
11
  type Option = {
package/dist/index.js CHANGED
@@ -280,8 +280,19 @@ function MultiPickerGroup({
280
280
  renderGroupIcon
281
281
  }) {
282
282
  const [open, setOpen] = (0, import_react2.useState)(true);
283
+ const [contentHeight, setContentHeight] = (0, import_react2.useState)(0);
284
+ const animatedHeight = (0, import_react2.useRef)(new import_react_native2.Animated.Value(0)).current;
285
+ const toggle = () => {
286
+ const toValue = open ? 0 : contentHeight;
287
+ import_react_native2.Animated.timing(animatedHeight, {
288
+ toValue,
289
+ duration: 250,
290
+ useNativeDriver: false
291
+ }).start();
292
+ setOpen(!open);
293
+ };
283
294
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.View, { style: styles.group, children: [
284
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.TouchableOpacity, { style: styles.header, onPress: () => setOpen(!open), children: [
295
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.TouchableOpacity, { style: styles.header, onPress: toggle, children: [
285
296
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style: styles.title, children: label }),
286
297
  renderGroupIcon?.({
287
298
  name: open ? "chevron-up" : "chevron-down",
@@ -289,7 +300,26 @@ function MultiPickerGroup({
289
300
  color: "#6B7280"
290
301
  })
291
302
  ] }),
292
- open && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.View, { style: { marginTop: 6 }, children })
303
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
304
+ import_react_native2.View,
305
+ {
306
+ style: styles.hidden,
307
+ onLayout: (e) => {
308
+ setContentHeight(e.nativeEvent.layout.height);
309
+ },
310
+ children
311
+ }
312
+ ),
313
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
314
+ import_react_native2.Animated.View,
315
+ {
316
+ style: {
317
+ height: animatedHeight,
318
+ overflow: "hidden"
319
+ },
320
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.View, { style: styles.content, children })
321
+ }
322
+ )
293
323
  ] });
294
324
  }
295
325
  var styles = import_react_native2.StyleSheet.create({
@@ -305,9 +335,14 @@ var styles = import_react_native2.StyleSheet.create({
305
335
  fontWeight: "600",
306
336
  fontSize: 14
307
337
  },
308
- fallback: {
309
- fontSize: 16,
310
- color: "#6B7280"
338
+ content: {
339
+ marginTop: 6
340
+ },
341
+ // invisible layout measurement
342
+ hidden: {
343
+ position: "absolute",
344
+ opacity: 0,
345
+ zIndex: -1
311
346
  }
312
347
  });
313
348
 
package/dist/index.mjs CHANGED
@@ -254,8 +254,14 @@ var toggleValue = (arr, value) => {
254
254
  };
255
255
 
256
256
  // src/components/MultiPickerGroup.tsx
257
- import { useState as useState2 } from "react";
258
- import { View as View2, Text as Text2, TouchableOpacity as TouchableOpacity2, StyleSheet as StyleSheet2 } from "react-native";
257
+ import { useRef, useState as useState2 } from "react";
258
+ import {
259
+ View as View2,
260
+ Text as Text2,
261
+ TouchableOpacity as TouchableOpacity2,
262
+ StyleSheet as StyleSheet2,
263
+ Animated
264
+ } from "react-native";
259
265
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
260
266
  function MultiPickerGroup({
261
267
  label,
@@ -263,8 +269,19 @@ function MultiPickerGroup({
263
269
  renderGroupIcon
264
270
  }) {
265
271
  const [open, setOpen] = useState2(true);
272
+ const [contentHeight, setContentHeight] = useState2(0);
273
+ const animatedHeight = useRef(new Animated.Value(0)).current;
274
+ const toggle = () => {
275
+ const toValue = open ? 0 : contentHeight;
276
+ Animated.timing(animatedHeight, {
277
+ toValue,
278
+ duration: 250,
279
+ useNativeDriver: false
280
+ }).start();
281
+ setOpen(!open);
282
+ };
266
283
  return /* @__PURE__ */ jsxs2(View2, { style: styles.group, children: [
267
- /* @__PURE__ */ jsxs2(TouchableOpacity2, { style: styles.header, onPress: () => setOpen(!open), children: [
284
+ /* @__PURE__ */ jsxs2(TouchableOpacity2, { style: styles.header, onPress: toggle, children: [
268
285
  /* @__PURE__ */ jsx2(Text2, { style: styles.title, children: label }),
269
286
  renderGroupIcon?.({
270
287
  name: open ? "chevron-up" : "chevron-down",
@@ -272,7 +289,26 @@ function MultiPickerGroup({
272
289
  color: "#6B7280"
273
290
  })
274
291
  ] }),
275
- open && /* @__PURE__ */ jsx2(View2, { style: { marginTop: 6 }, children })
292
+ /* @__PURE__ */ jsx2(
293
+ View2,
294
+ {
295
+ style: styles.hidden,
296
+ onLayout: (e) => {
297
+ setContentHeight(e.nativeEvent.layout.height);
298
+ },
299
+ children
300
+ }
301
+ ),
302
+ /* @__PURE__ */ jsx2(
303
+ Animated.View,
304
+ {
305
+ style: {
306
+ height: animatedHeight,
307
+ overflow: "hidden"
308
+ },
309
+ children: /* @__PURE__ */ jsx2(View2, { style: styles.content, children })
310
+ }
311
+ )
276
312
  ] });
277
313
  }
278
314
  var styles = StyleSheet2.create({
@@ -288,9 +324,14 @@ var styles = StyleSheet2.create({
288
324
  fontWeight: "600",
289
325
  fontSize: 14
290
326
  },
291
- fallback: {
292
- fontSize: 16,
293
- color: "#6B7280"
327
+ content: {
328
+ marginTop: 6
329
+ },
330
+ // invisible layout measurement
331
+ hidden: {
332
+ position: "absolute",
333
+ opacity: 0,
334
+ zIndex: -1
294
335
  }
295
336
  });
296
337
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaushverse/pickify",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
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",