@gaozh1024/rn-kit 0.3.0 → 0.3.2

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.mjs CHANGED
@@ -1243,7 +1243,7 @@ var styles = StyleSheet2.create({
1243
1243
  flex: 1
1244
1244
  }
1245
1245
  });
1246
- function Page({
1246
+ function AppScreen({
1247
1247
  children,
1248
1248
  className,
1249
1249
  ...props
@@ -1569,7 +1569,8 @@ function Card({
1569
1569
  }
1570
1570
 
1571
1571
  // src/ui/display/Icon.tsx
1572
- import MaterialIcons from "react-native-vector-icons/MaterialIcons";
1572
+ import { Text as Text2 } from "react-native";
1573
+ import { MaterialIcons } from "@expo/vector-icons";
1573
1574
  import { jsx as jsx16 } from "nativewind/jsx-runtime";
1574
1575
  var sizeMap2 = {
1575
1576
  xs: 16,
@@ -1578,6 +1579,12 @@ var sizeMap2 = {
1578
1579
  lg: 32,
1579
1580
  xl: 48
1580
1581
  };
1582
+ function isComponentLike(value) {
1583
+ if (typeof value === "function") return true;
1584
+ if (typeof value !== "object" || value === null) return false;
1585
+ return "$$typeof" in value;
1586
+ }
1587
+ var MaterialIconComponent = isComponentLike(MaterialIcons) ? MaterialIcons : void 0;
1581
1588
  function resolveSize(size = "md") {
1582
1589
  if (typeof size === "number") return size;
1583
1590
  return sizeMap2[size] || 24;
@@ -1586,11 +1593,37 @@ function Icon({ name, size = "md", color = "gray-600", style, onPress, testID })
1586
1593
  const { theme, isDark } = useOptionalTheme();
1587
1594
  const resolvedSize = resolveSize(size);
1588
1595
  const resolvedColor = resolveNamedColor(color, theme, isDark) ?? color;
1596
+ const fallback = /* @__PURE__ */ jsx16(
1597
+ Text2,
1598
+ {
1599
+ style: [
1600
+ {
1601
+ color: resolvedColor,
1602
+ fontSize: resolvedSize,
1603
+ lineHeight: resolvedSize
1604
+ },
1605
+ style
1606
+ ],
1607
+ testID,
1608
+ children: "\u25A1"
1609
+ }
1610
+ );
1611
+ if (!MaterialIconComponent) {
1612
+ return onPress ? /* @__PURE__ */ jsx16(AppPressable, { onPress, children: fallback }) : fallback;
1613
+ }
1589
1614
  if (onPress) {
1590
- return /* @__PURE__ */ jsx16(AppPressable, { onPress, testID, children: /* @__PURE__ */ jsx16(MaterialIcons, { name, size: resolvedSize, color: resolvedColor, style }) });
1615
+ return /* @__PURE__ */ jsx16(AppPressable, { onPress, testID, children: /* @__PURE__ */ jsx16(
1616
+ MaterialIconComponent,
1617
+ {
1618
+ name,
1619
+ size: resolvedSize,
1620
+ color: resolvedColor,
1621
+ style
1622
+ }
1623
+ ) });
1591
1624
  }
1592
1625
  return /* @__PURE__ */ jsx16(
1593
- MaterialIcons,
1626
+ MaterialIconComponent,
1594
1627
  {
1595
1628
  name,
1596
1629
  size: resolvedSize,
@@ -1840,12 +1873,18 @@ function EmptyState({
1840
1873
  description && /* @__PURE__ */ jsx18(AppText, { size: "sm", className: "mt-2", style: { color: colors.textMuted }, children: description })
1841
1874
  ] });
1842
1875
  }
1843
- function ErrorState({ error, onRetry }) {
1876
+ function ErrorState({
1877
+ error,
1878
+ onRetry,
1879
+ errorTitle,
1880
+ errorDescription,
1881
+ retryText
1882
+ }) {
1844
1883
  const colors = useThemeColors();
1845
1884
  return /* @__PURE__ */ jsxs4(Center, { py: 20, children: [
1846
1885
  /* @__PURE__ */ jsx18(Icon, { name: "error-outline", size: 64, color: "error-300" }),
1847
- /* @__PURE__ */ jsx18(AppText, { size: "lg", weight: "medium", color: "error-500", className: "mt-4", children: "\u52A0\u8F7D\u5931\u8D25" }),
1848
- /* @__PURE__ */ jsx18(AppText, { size: "sm", style: { color: colors.textMuted }, className: "mt-2 text-center px-8", children: error.message || "\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5" }),
1886
+ /* @__PURE__ */ jsx18(AppText, { size: "lg", weight: "medium", color: "error-500", className: "mt-4", children: errorTitle || "\u52A0\u8F7D\u5931\u8D25" }),
1887
+ /* @__PURE__ */ jsx18(AppText, { size: "sm", style: { color: colors.textMuted }, className: "mt-2 text-center px-8", children: error.message || errorDescription || "\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5" }),
1849
1888
  onRetry && /* @__PURE__ */ jsx18(
1850
1889
  AppPressable,
1851
1890
  {
@@ -1855,7 +1894,7 @@ function ErrorState({ error, onRetry }) {
1855
1894
  styles3.retryButton,
1856
1895
  { backgroundColor: colors.cardElevated, borderColor: colors.border }
1857
1896
  ],
1858
- children: /* @__PURE__ */ jsx18(AppText, { style: { color: colors.textSecondary }, className: "text-center", children: "\u91CD\u65B0\u52A0\u8F7D" })
1897
+ children: /* @__PURE__ */ jsx18(AppText, { style: { color: colors.textSecondary }, className: "text-center", children: retryText || "\u91CD\u65B0\u52A0\u8F7D" })
1859
1898
  }
1860
1899
  )
1861
1900
  ] });
@@ -1886,6 +1925,9 @@ function AppList({
1886
1925
  onEndReachedThreshold = 0.5,
1887
1926
  error,
1888
1927
  onRetry,
1928
+ errorTitle,
1929
+ errorDescription,
1930
+ retryText,
1889
1931
  emptyTitle,
1890
1932
  emptyDescription,
1891
1933
  emptyIcon,
@@ -1954,7 +1996,16 @@ function AppList({
1954
1996
  );
1955
1997
  }
1956
1998
  if (error && data.length === 0) {
1957
- return /* @__PURE__ */ jsx18(Center, { style, children: /* @__PURE__ */ jsx18(ErrorState, { error, onRetry }) });
1999
+ return /* @__PURE__ */ jsx18(Center, { style, children: /* @__PURE__ */ jsx18(
2000
+ ErrorState,
2001
+ {
2002
+ error,
2003
+ onRetry,
2004
+ errorTitle,
2005
+ errorDescription,
2006
+ retryText
2007
+ }
2008
+ ) });
1958
2009
  }
1959
2010
  const ListEmptyComponent = useMemo3(() => {
1960
2011
  if (EmptyComponent) return /* @__PURE__ */ jsx18(EmptyComponent, {});
@@ -2116,14 +2167,7 @@ function PageDrawer({
2116
2167
  }
2117
2168
  ),
2118
2169
  /* @__PURE__ */ jsx19(AppScrollView, { flex: true, className: "px-4 py-4", children }),
2119
- footer && /* @__PURE__ */ jsx19(
2120
- AppView,
2121
- {
2122
- className: "px-4 py-4",
2123
- style: [styles4.footer, { borderTopColor: colors.divider }],
2124
- children: footer
2125
- }
2126
- )
2170
+ footer && /* @__PURE__ */ jsx19(AppView, { className: "px-4 py-4", style: [styles4.footer, { borderTopColor: colors.divider }], children: footer })
2127
2171
  ]
2128
2172
  }
2129
2173
  );
@@ -2785,6 +2829,9 @@ import {
2785
2829
  StyleSheet as StyleSheet11
2786
2830
  } from "react-native";
2787
2831
  import { Fragment as Fragment2, jsx as jsx28, jsxs as jsxs10 } from "nativewind/jsx-runtime";
2832
+ function formatSelectedCountText(template, count) {
2833
+ return template.replace("{{count}}", String(count));
2834
+ }
2788
2835
  function Select({
2789
2836
  value,
2790
2837
  onChange,
@@ -2795,6 +2842,12 @@ function Select({
2795
2842
  onSearch,
2796
2843
  disabled = false,
2797
2844
  clearable = true,
2845
+ singleSelectTitle = "\u8BF7\u9009\u62E9",
2846
+ multipleSelectTitle = "\u9009\u62E9\u9009\u9879",
2847
+ searchPlaceholder = "\u641C\u7D22...",
2848
+ emptyText = "\u6682\u65E0\u9009\u9879",
2849
+ selectedCountText = "\u5DF2\u9009\u62E9 {{count}} \u9879",
2850
+ confirmText = "\u786E\u5B9A",
2798
2851
  className
2799
2852
  }) {
2800
2853
  const colors = useFormThemeColors();
@@ -2918,7 +2971,7 @@ function Select({
2918
2971
  className: "px-4 py-3",
2919
2972
  style: [styles10.header, { borderBottomColor: colors.divider }],
2920
2973
  children: [
2921
- /* @__PURE__ */ jsx28(AppText, { className: "text-lg font-semibold", style: { color: colors.text }, children: multiple ? "\u9009\u62E9\u9009\u9879" : "\u8BF7\u9009\u62E9" }),
2974
+ /* @__PURE__ */ jsx28(AppText, { className: "text-lg font-semibold", style: { color: colors.text }, children: multiple ? multipleSelectTitle : singleSelectTitle }),
2922
2975
  /* @__PURE__ */ jsx28(TouchableOpacity5, { onPress: () => setVisible(false), children: /* @__PURE__ */ jsx28(Icon, { name: "close", size: "md", color: colors.icon }) })
2923
2976
  ]
2924
2977
  }
@@ -2942,7 +2995,7 @@ function Select({
2942
2995
  {
2943
2996
  className: "flex-1 text-base",
2944
2997
  style: { color: colors.text },
2945
- placeholder: "\u641C\u7D22...",
2998
+ placeholder: searchPlaceholder,
2946
2999
  placeholderTextColor: colors.textMuted,
2947
3000
  value: searchKeyword,
2948
3001
  onChangeText: handleSearch,
@@ -2961,7 +3014,7 @@ function Select({
2961
3014
  data: filteredOptions,
2962
3015
  keyExtractor: (item) => item.value,
2963
3016
  renderItem: renderOption,
2964
- ListEmptyComponent: /* @__PURE__ */ jsx28(AppView, { center: true, className: "py-8", children: /* @__PURE__ */ jsx28(AppText, { style: { color: colors.textMuted }, children: "\u6682\u65E0\u9009\u9879" }) })
3017
+ ListEmptyComponent: /* @__PURE__ */ jsx28(AppView, { center: true, className: "py-8", children: /* @__PURE__ */ jsx28(AppText, { style: { color: colors.textMuted }, children: emptyText }) })
2965
3018
  }
2966
3019
  ),
2967
3020
  multiple && /* @__PURE__ */ jsxs10(
@@ -2973,18 +3026,14 @@ function Select({
2973
3026
  className: "px-4 py-3",
2974
3027
  style: [styles10.footer, { borderTopColor: colors.divider }],
2975
3028
  children: [
2976
- /* @__PURE__ */ jsxs10(AppText, { style: { color: colors.textMuted }, children: [
2977
- "\u5DF2\u9009\u62E9 ",
2978
- selectedValues.length,
2979
- " \u9879"
2980
- ] }),
3029
+ /* @__PURE__ */ jsx28(AppText, { style: { color: colors.textMuted }, children: formatSelectedCountText(selectedCountText, selectedValues.length) }),
2981
3030
  /* @__PURE__ */ jsx28(
2982
3031
  TouchableOpacity5,
2983
3032
  {
2984
3033
  className: "px-4 py-2 rounded-lg",
2985
3034
  style: { backgroundColor: colors.primary },
2986
3035
  onPress: () => setVisible(false),
2987
- children: /* @__PURE__ */ jsx28(AppText, { className: "font-medium", style: { color: colors.textInverse }, children: "\u786E\u5B9A" })
3036
+ children: /* @__PURE__ */ jsx28(AppText, { className: "font-medium", style: { color: colors.textInverse }, children: confirmText })
2988
3037
  }
2989
3038
  )
2990
3039
  ]
@@ -3075,7 +3124,17 @@ function DatePicker({
3075
3124
  format = "yyyy-MM-dd",
3076
3125
  minDate,
3077
3126
  maxDate,
3078
- className
3127
+ className,
3128
+ cancelText = "\u53D6\u6D88",
3129
+ confirmText = "\u786E\u5B9A",
3130
+ pickerTitle = "\u9009\u62E9\u65E5\u671F",
3131
+ pickerDateFormat = "yyyy\u5E74MM\u6708dd\u65E5",
3132
+ yearLabel = "\u5E74",
3133
+ monthLabel = "\u6708",
3134
+ dayLabel = "\u65E5",
3135
+ todayText = "\u4ECA\u5929",
3136
+ minDateText = "\u6700\u65E9",
3137
+ maxDateText = "\u6700\u665A"
3079
3138
  }) {
3080
3139
  const colors = useFormThemeColors();
3081
3140
  const [visible, setVisible] = useState18(false);
@@ -3169,18 +3228,18 @@ function DatePicker({
3169
3228
  className: "px-4 py-3",
3170
3229
  style: [styles11.header, { borderBottomColor: colors.divider }],
3171
3230
  children: [
3172
- /* @__PURE__ */ jsx29(TouchableOpacity6, { onPress: () => setVisible(false), children: /* @__PURE__ */ jsx29(AppText, { style: { color: colors.textMuted }, children: "\u53D6\u6D88" }) }),
3173
- /* @__PURE__ */ jsx29(AppText, { className: "text-lg font-semibold", style: { color: colors.text }, children: "\u9009\u62E9\u65E5\u671F" }),
3174
- /* @__PURE__ */ jsx29(TouchableOpacity6, { onPress: handleConfirm, children: /* @__PURE__ */ jsx29(AppText, { style: { color: colors.primary }, className: "font-medium", children: "\u786E\u5B9A" }) })
3231
+ /* @__PURE__ */ jsx29(TouchableOpacity6, { onPress: () => setVisible(false), children: /* @__PURE__ */ jsx29(AppText, { style: { color: colors.textMuted }, children: cancelText }) }),
3232
+ /* @__PURE__ */ jsx29(AppText, { className: "text-lg font-semibold", style: { color: colors.text }, children: pickerTitle }),
3233
+ /* @__PURE__ */ jsx29(TouchableOpacity6, { onPress: handleConfirm, children: /* @__PURE__ */ jsx29(AppText, { style: { color: colors.primary }, className: "font-medium", children: confirmText }) })
3175
3234
  ]
3176
3235
  }
3177
3236
  ),
3178
- /* @__PURE__ */ jsx29(AppView, { center: true, className: "py-4", style: { backgroundColor: colors.headerSurface }, children: /* @__PURE__ */ jsx29(AppText, { className: "text-2xl font-semibold", style: { color: colors.text }, children: formatDate(tempDate, "yyyy\u5E74MM\u6708dd\u65E5") }) }),
3237
+ /* @__PURE__ */ jsx29(AppView, { center: true, className: "py-4", style: { backgroundColor: colors.headerSurface }, children: /* @__PURE__ */ jsx29(AppText, { className: "text-2xl font-semibold", style: { color: colors.text }, children: formatDate(tempDate, pickerDateFormat) }) }),
3179
3238
  /* @__PURE__ */ jsxs11(AppView, { row: true, className: "h-48", children: [
3180
3239
  /* @__PURE__ */ jsx29(
3181
3240
  PickerColumn,
3182
3241
  {
3183
- title: "\u5E74",
3242
+ title: yearLabel,
3184
3243
  values: years,
3185
3244
  selectedValue: tempDate.getFullYear(),
3186
3245
  onSelect: (year) => updateTempDate(year),
@@ -3192,7 +3251,7 @@ function DatePicker({
3192
3251
  /* @__PURE__ */ jsx29(
3193
3252
  PickerColumn,
3194
3253
  {
3195
- title: "\u6708",
3254
+ title: monthLabel,
3196
3255
  values: months,
3197
3256
  selectedValue: tempDate.getMonth() + 1,
3198
3257
  onSelect: (month) => updateTempDate(void 0, month),
@@ -3205,7 +3264,7 @@ function DatePicker({
3205
3264
  /* @__PURE__ */ jsx29(
3206
3265
  PickerColumn,
3207
3266
  {
3208
- title: "\u65E5",
3267
+ title: dayLabel,
3209
3268
  values: days,
3210
3269
  selectedValue: tempDate.getDate(),
3211
3270
  onSelect: (day) => updateTempDate(void 0, void 0, day),
@@ -3227,7 +3286,7 @@ function DatePicker({
3227
3286
  className: "flex-1 py-2 items-center rounded-lg",
3228
3287
  style: { backgroundColor: colors.surfaceMuted },
3229
3288
  onPress: () => setTempDate(/* @__PURE__ */ new Date()),
3230
- children: /* @__PURE__ */ jsx29(AppText, { style: { color: colors.text }, children: "\u4ECA\u5929" })
3289
+ children: /* @__PURE__ */ jsx29(AppText, { style: { color: colors.text }, children: todayText })
3231
3290
  }
3232
3291
  ),
3233
3292
  minDate && /* @__PURE__ */ jsx29(
@@ -3236,7 +3295,7 @@ function DatePicker({
3236
3295
  className: "flex-1 py-2 items-center rounded-lg",
3237
3296
  style: { backgroundColor: colors.surfaceMuted },
3238
3297
  onPress: () => setTempDate(minDate),
3239
- children: /* @__PURE__ */ jsx29(AppText, { style: { color: colors.text }, children: "\u6700\u65E9" })
3298
+ children: /* @__PURE__ */ jsx29(AppText, { style: { color: colors.text }, children: minDateText })
3240
3299
  }
3241
3300
  ),
3242
3301
  maxDate && /* @__PURE__ */ jsx29(
@@ -3245,7 +3304,7 @@ function DatePicker({
3245
3304
  className: "flex-1 py-2 items-center rounded-lg",
3246
3305
  style: { backgroundColor: colors.surfaceMuted },
3247
3306
  onPress: () => setTempDate(maxDate),
3248
- children: /* @__PURE__ */ jsx29(AppText, { style: { color: colors.text }, children: "\u6700\u665A" })
3307
+ children: /* @__PURE__ */ jsx29(AppText, { style: { color: colors.text }, children: maxDateText })
3249
3308
  }
3250
3309
  )
3251
3310
  ]
@@ -4268,6 +4327,7 @@ import { SafeAreaProvider } from "react-native-safe-area-context";
4268
4327
 
4269
4328
  // src/overlay/AppStatusBar.tsx
4270
4329
  import { StatusBar } from "react-native";
4330
+ import { useIsFocused as useIsFocused2 } from "@react-navigation/native";
4271
4331
  import { jsx as jsx38 } from "nativewind/jsx-runtime";
4272
4332
  function AppStatusBar({
4273
4333
  barStyle = "auto",
@@ -4288,6 +4348,11 @@ function AppStatusBar({
4288
4348
  }
4289
4349
  );
4290
4350
  }
4351
+ function AppFocusedStatusBar(props) {
4352
+ const isFocused = useIsFocused2();
4353
+ if (!isFocused) return null;
4354
+ return /* @__PURE__ */ jsx38(AppStatusBar, { ...props });
4355
+ }
4291
4356
 
4292
4357
  // src/overlay/loading/provider.tsx
4293
4358
  import { useState as useState27, useCallback as useCallback19 } from "react";
@@ -4626,12 +4691,14 @@ export {
4626
4691
  ActionIcons,
4627
4692
  Alert,
4628
4693
  AppButton,
4694
+ AppFocusedStatusBar,
4629
4695
  AppHeader,
4630
4696
  AppImage,
4631
4697
  AppInput,
4632
4698
  AppList,
4633
4699
  AppPressable,
4634
4700
  AppProvider,
4701
+ AppScreen,
4635
4702
  AppScrollView,
4636
4703
  AppStatusBar,
4637
4704
  AppText,
@@ -4656,7 +4723,6 @@ export {
4656
4723
  NavigationIcons,
4657
4724
  NavigationProvider,
4658
4725
  OverlayProvider,
4659
- Page,
4660
4726
  PageDrawer,
4661
4727
  Progress,
4662
4728
  Radio,