react-native-better-html 1.0.24 → 1.0.25

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
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
2
  import {
3
- useTheme as useTheme15,
3
+ useTheme as useTheme16,
4
4
  useLoader as useLoader2,
5
5
  useLoaderControls,
6
6
  countries,
@@ -14,7 +14,7 @@ import {
14
14
  eventStopPropagation,
15
15
  eventPreventStop,
16
16
  getPluralWord,
17
- useBooleanState as useBooleanState6,
17
+ useBooleanState as useBooleanState7,
18
18
  useDebounceState,
19
19
  loaderControls,
20
20
  colorThemeControls
@@ -452,6 +452,22 @@ function useForm(options) {
452
452
  },
453
453
  [values, setFieldValue]
454
454
  );
455
+ const getCheckBoxProps = useCallback(
456
+ (field, insideListItem) => {
457
+ return insideListItem ? {
458
+ checkBoxIsChecked: values[field],
459
+ checkBoxOnChange: (value) => {
460
+ setFieldValue(field, value);
461
+ }
462
+ } : {
463
+ isChecked: values[field],
464
+ onChange: (value) => {
465
+ setFieldValue(field, value);
466
+ }
467
+ };
468
+ },
469
+ [values, setFieldValue]
470
+ );
455
471
  const reset = useCallback(() => {
456
472
  setValues(defaultValues);
457
473
  setErrors({});
@@ -476,6 +492,7 @@ function useForm(options) {
476
492
  setFieldsValue,
477
493
  getInputFieldProps,
478
494
  getSwitchProps,
495
+ getCheckBoxProps,
479
496
  focusField,
480
497
  inputFieldRefs: inputFieldRefs.current,
481
498
  validate: validateForm,
@@ -2217,10 +2234,10 @@ function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
2217
2234
  width: "100%",
2218
2235
  height: ballGap + ballSize + ballGap,
2219
2236
  borderRadius: 999,
2220
- initialOpacity: 1,
2221
- animateOpacity: disabled ? 0.6 : 1,
2222
2237
  initialBackgroundColor: theme2.colors.border,
2223
2238
  animateBackgroundColor: enabled ? theme2.colors.primary : theme2.colors.border,
2239
+ initialOpacity: 1,
2240
+ animateOpacity: disabled ? 0.6 : 1,
2224
2241
  children: /* @__PURE__ */ jsx13(
2225
2242
  Animate_default.View,
2226
2243
  {
@@ -2228,6 +2245,9 @@ function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
2228
2245
  height: ballSize,
2229
2246
  top: ballGap,
2230
2247
  borderRadius: 999,
2248
+ transitionType: "spring",
2249
+ transitionDamping: 20,
2250
+ transitionStiffness: 230,
2231
2251
  backgroundColor: theme2.colors.backgroundContent,
2232
2252
  initialX: ballGap,
2233
2253
  animateX: enabled ? holderWidth - ballGap - ballSize : ballGap
@@ -2240,28 +2260,95 @@ function Switch({ isEnabled, defaultIsEnabled, disabled, onChange }) {
2240
2260
  }
2241
2261
  var Switch_default = memo13(Switch);
2242
2262
 
2243
- // src/components/StatusBar.tsx
2244
- import { memo as memo14 } from "react";
2245
- import { useTheme as useTheme13 } from "react-better-core";
2246
- import { StatusBar as NativeStatusBar, Platform as Platform7 } from "react-native";
2263
+ // src/components/CheckBox.tsx
2264
+ import { memo as memo14, useCallback as useCallback8, useEffect as useEffect8 } from "react";
2265
+ import { Platform as Platform7 } from "react-native";
2266
+ import { useBooleanState as useBooleanState6, useTheme as useTheme13 } from "react-better-core";
2247
2267
  import { jsx as jsx14 } from "react/jsx-runtime";
2248
- function StatusBar({ darkStatusBar, hidden, barStyle, androidBarStyle, iOSBarStyle }) {
2268
+ function CheckBox({ isChecked, defaultIsChecked, size = 36, disabled, onChange }) {
2249
2269
  const theme2 = useTheme13();
2270
+ const [checked, setChecked] = useBooleanState6(isChecked ?? defaultIsChecked);
2271
+ const onPressElement = useCallback8(() => {
2272
+ onChange?.(!checked);
2273
+ setChecked.toggle();
2274
+ }, [onChange, checked]);
2275
+ useEffect8(() => {
2276
+ if (isChecked === void 0) return;
2277
+ setChecked.setState(isChecked);
2278
+ }, [isChecked]);
2250
2279
  return /* @__PURE__ */ jsx14(
2280
+ View_default,
2281
+ {
2282
+ width: size,
2283
+ borderRadius: theme2.styles.borderRadius,
2284
+ pressStrength: pressStrength().p05,
2285
+ disabled,
2286
+ onPress: !disabled ? onPressElement : void 0,
2287
+ children: /* @__PURE__ */ jsx14(
2288
+ Animate_default.View,
2289
+ {
2290
+ width: "100%",
2291
+ height: size,
2292
+ borderWidth: 1,
2293
+ borderRadius: theme2.styles.borderRadius,
2294
+ initialBackgroundColor: theme2.colors.backgroundContent,
2295
+ animateBackgroundColor: checked ? theme2.colors.primary : theme2.colors.backgroundContent,
2296
+ initialBorderColor: theme2.colors.border,
2297
+ animateBorderColor: checked ? theme2.colors.primary : theme2.colors.border,
2298
+ initialOpacity: 1,
2299
+ animateOpacity: disabled ? 0.6 : 1,
2300
+ children: /* @__PURE__ */ jsx14(
2301
+ Animate_default.View,
2302
+ {
2303
+ width: "100%",
2304
+ height: "100%",
2305
+ alignItems: "center",
2306
+ justifyContent: "center",
2307
+ transitionType: "spring",
2308
+ transitionDamping: 20,
2309
+ transitionStiffness: 230,
2310
+ initialScale: 0,
2311
+ animateScale: checked ? 1 : 0,
2312
+ children: /* @__PURE__ */ jsx14(
2313
+ Icon_default,
2314
+ {
2315
+ name: "check",
2316
+ nameIOS: "checkmark",
2317
+ size: size * (Platform7.OS === "ios" ? 0.5 : 0.6),
2318
+ color: theme2.colors.base
2319
+ }
2320
+ )
2321
+ }
2322
+ )
2323
+ }
2324
+ )
2325
+ }
2326
+ );
2327
+ }
2328
+ var CheckBox_default = memo14(CheckBox);
2329
+
2330
+ // src/components/StatusBar.tsx
2331
+ import { memo as memo15 } from "react";
2332
+ import { useTheme as useTheme14 } from "react-better-core";
2333
+ import { StatusBar as NativeStatusBar, Platform as Platform8 } from "react-native";
2334
+ import { jsx as jsx15 } from "react/jsx-runtime";
2335
+ function StatusBar({ darkStatusBar, hidden, barStyle, androidBarStyle, iOSBarStyle }) {
2336
+ const theme2 = useTheme14();
2337
+ return /* @__PURE__ */ jsx15(
2251
2338
  NativeStatusBar,
2252
2339
  {
2253
2340
  backgroundColor: darkStatusBar ? theme2.colors.backgroundSecondary : void 0,
2254
- barStyle: barStyle ?? (Platform7.OS === "android" ? androidBarStyle : iOSBarStyle),
2341
+ barStyle: barStyle ?? (Platform8.OS === "android" ? androidBarStyle : iOSBarStyle),
2255
2342
  hidden
2256
2343
  }
2257
2344
  );
2258
2345
  }
2259
- var StatusBar_default = memo14(StatusBar);
2346
+ var StatusBar_default = memo15(StatusBar);
2260
2347
 
2261
2348
  // src/components/ListItem.tsx
2262
- import { memo as memo15 } from "react";
2263
- import { useTheme as useTheme14 } from "react-better-core";
2264
- import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
2349
+ import { memo as memo16 } from "react";
2350
+ import { useTheme as useTheme15 } from "react-better-core";
2351
+ import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
2265
2352
  function ListItem({
2266
2353
  icon,
2267
2354
  iconIOS,
@@ -2275,12 +2362,14 @@ function ListItem({
2275
2362
  rightValue,
2276
2363
  rightValueSelectable,
2277
2364
  switchIsEnabled,
2278
- switchOnChange
2365
+ switchOnChange,
2366
+ checkBoxIsChecked,
2367
+ checkBoxOnChange
2279
2368
  }) {
2280
- const theme2 = useTheme14();
2369
+ const theme2 = useTheme15();
2281
2370
  const device = useDevice();
2282
2371
  const sideSpace = theme2.styles.space;
2283
- return /* @__PURE__ */ jsx15(
2372
+ return /* @__PURE__ */ jsx16(
2284
2373
  View_default,
2285
2374
  {
2286
2375
  width: insideScreenHolder ? device.windowDimensions.width : "100%",
@@ -2291,14 +2380,14 @@ function ListItem({
2291
2380
  pressStrength: pressStrength().p05,
2292
2381
  onPress,
2293
2382
  children: /* @__PURE__ */ jsxs7(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.space, children: [
2294
- icon && /* @__PURE__ */ jsx15(Icon_default, { name: icon, nameIOS: iconIOS, size: 22, color: theme2.colors.primary }),
2295
- /* @__PURE__ */ jsx15(View_default, { flex: 1, flexDirection: "row", alignItems: "center", gap: theme2.styles.gap, children: /* @__PURE__ */ jsxs7(View_default, { flex: 1, children: [
2296
- title && /* @__PURE__ */ jsx15(Text_default, { fontSize: 20, fontWeight: 700, children: title }),
2297
- description && /* @__PURE__ */ jsx15(Text_default.body, { selectable: descriptionSelectable, children: description })
2383
+ icon && /* @__PURE__ */ jsx16(Icon_default, { name: icon, nameIOS: iconIOS, size: 22, color: theme2.colors.primary }),
2384
+ /* @__PURE__ */ jsx16(View_default, { flex: 1, flexDirection: "row", alignItems: "center", gap: theme2.styles.gap, children: /* @__PURE__ */ jsxs7(View_default, { flex: 1, children: [
2385
+ title && /* @__PURE__ */ jsx16(Text_default, { fontSize: 20, fontWeight: 700, children: title }),
2386
+ description && /* @__PURE__ */ jsx16(Text_default.body, { selectable: descriptionSelectable, children: description })
2298
2387
  ] }) }),
2299
- rightElement ? /* @__PURE__ */ jsx15(Fragment5, { children: rightValue !== void 0 || rightElement === "arrow" ? /* @__PURE__ */ jsxs7(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.gap / 2, children: [
2300
- rightValue !== void 0 && /* @__PURE__ */ jsx15(Text_default, { fontSize: 14, fontWeight: 700, selectable: rightValueSelectable, children: rightValue }),
2301
- rightElement === "arrow" && /* @__PURE__ */ jsx15(
2388
+ rightElement ? /* @__PURE__ */ jsx16(Fragment5, { children: rightValue !== void 0 || rightElement === "arrow" ? /* @__PURE__ */ jsxs7(View_default, { isRow: true, alignItems: "center", gap: theme2.styles.gap / 2, children: [
2389
+ rightValue !== void 0 && /* @__PURE__ */ jsx16(Text_default, { fontSize: 14, fontWeight: 700, selectable: rightValueSelectable, children: rightValue }),
2390
+ rightElement === "arrow" && /* @__PURE__ */ jsx16(
2302
2391
  Icon_default,
2303
2392
  {
2304
2393
  name: "chevronRight",
@@ -2306,16 +2395,17 @@ function ListItem({
2306
2395
  color: rightValue !== void 0 ? theme2.colors.textPrimary : theme2.colors.textSecondary
2307
2396
  }
2308
2397
  )
2309
- ] }) : rightElement === "switch" ? /* @__PURE__ */ jsx15(Switch_default, { isEnabled: switchIsEnabled, onChange: switchOnChange }) : void 0 }) : void 0
2398
+ ] }) : rightElement === "switch" ? /* @__PURE__ */ jsx16(Switch_default, { isEnabled: switchIsEnabled, onChange: switchOnChange }) : rightElement === "checkBox" ? /* @__PURE__ */ jsx16(CheckBox_default, { isChecked: checkBoxIsChecked, onChange: checkBoxOnChange }) : void 0 }) : void 0
2310
2399
  ] })
2311
2400
  }
2312
2401
  );
2313
2402
  }
2314
- var ListItem_default = memo15(ListItem);
2403
+ var ListItem_default = memo16(ListItem);
2315
2404
  export {
2316
2405
  Animate_default as Animate,
2317
2406
  BetterComponentsProvider_default as BetterComponentsProvider,
2318
2407
  Button_default as Button,
2408
+ CheckBox_default as CheckBox,
2319
2409
  Icon_default as Icon,
2320
2410
  Image_default as Image,
2321
2411
  InputField_default as InputField,
@@ -2349,7 +2439,7 @@ export {
2349
2439
  saturateColor,
2350
2440
  useAlertControls,
2351
2441
  useBetterComponentsContext,
2352
- useBooleanState6 as useBooleanState,
2442
+ useBooleanState7 as useBooleanState,
2353
2443
  useDebounceState,
2354
2444
  useDevice,
2355
2445
  useEventEmitter,
@@ -2357,6 +2447,6 @@ export {
2357
2447
  useKeyboard,
2358
2448
  useLoader2 as useLoader,
2359
2449
  useLoaderControls,
2360
- useTheme15 as useTheme
2450
+ useTheme16 as useTheme
2361
2451
  };
2362
2452
  //# sourceMappingURL=index.mjs.map