@react-typed-forms/schemas-rn 2.0.0 → 2.1.0

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/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { useMemo, isValidElement, useEffect, Fragment as Fragment$1, useId } from 'react';
3
3
  import { fontAwesomeIcon, deepMerge, IconLibrary, createDataRenderer, DataRenderType, rendererClass, FieldType, getLoadingControl, getHasMoreControl, getRefreshingControl, NoOpControlActionContext, DisplayDataType, coerceToString, getOverrideClass, createLayoutRenderer, renderLayoutParts, createVisibilityRenderer, mergeObjects, isArrayRenderer, createArrayActions, getLengthRestrictions, applyArrayLengthRestrictions, fieldOptionAdornment, setIncluded, useElementSelectedRenderer, createGroupRenderer, GroupRenderType, schemaDataForFieldRef, getLastDefinedValue, getNullToggler, createAction, IconPlacement, isTabsRenderer, isGridRenderer, isWizardRenderer, isDialogRenderer, isAccordionRenderer, isSelectChildRenderer, isFlexRenderer, isInlineRenderer, useExpression, createActionRenderer, ActionStyle, isDataGroupRenderer, isDisplayOnlyRenderer, hasOptions, isTextfieldRenderer, isOptionalAdornment, isSetFieldAdornment, wrapLayout, isIconAdornment, appendMarkupAt, AdornmentPlacement, isAccordionAdornment, LabelType } from '@react-typed-forms/schemas';
4
- import { View, Text, Pressable, TextInput, Dimensions, Platform, StyleSheet, useWindowDimensions, TouchableOpacity, FlatList, RefreshControl, ActivityIndicator } from 'react-native';
4
+ import { View, Text, Pressable, TextInput, Dimensions, Platform, StyleSheet, useWindowDimensions, TouchableOpacity, FlatList, RefreshControl, ActivityIndicator, ScrollView as ScrollView$1 } from 'react-native';
5
5
  import { jsx, jsxs, Fragment } from 'nativewind/jsx-runtime';
6
6
  import { cva } from 'class-variance-authority';
7
7
  import clsx$1, { clsx } from 'clsx';
@@ -170,14 +170,14 @@ function cn(...inputs) {
170
170
  return twMerge(clsx(inputs));
171
171
  }
172
172
 
173
- const _excluded$b = ["className", "asChild"];
173
+ const _excluded$d = ["className", "asChild"];
174
174
  const TextClassContext = /*#__PURE__*/React.createContext(undefined);
175
175
  const RNText = /*#__PURE__*/React.forwardRef((_ref, ref) => {
176
176
  let {
177
177
  className,
178
178
  asChild = false
179
179
  } = _ref,
180
- props = _objectWithoutPropertiesLoose(_ref, _excluded$b);
180
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
181
181
  const textClass = React.useContext(TextClassContext);
182
182
  const Component = asChild ? Slot.Text : Text;
183
183
  return jsx(Component, _extends({
@@ -187,7 +187,7 @@ const RNText = /*#__PURE__*/React.forwardRef((_ref, ref) => {
187
187
  });
188
188
  RNText.displayName = "RNText";
189
189
 
190
- const _excluded$a = ["className", "variant", "size"];
190
+ const _excluded$c = ["className", "variant", "size"];
191
191
  const buttonVariants = cva("group flex items-center justify-center rounded-md web:ring-offset-background web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2", {
192
192
  variants: {
193
193
  variant: {
@@ -238,7 +238,7 @@ const RNButton$1 = /*#__PURE__*/React.forwardRef((_ref, ref) => {
238
238
  variant,
239
239
  size
240
240
  } = _ref,
241
- props = _objectWithoutPropertiesLoose(_ref, _excluded$a);
241
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
242
242
  return jsx(TextClassContext.Provider, {
243
243
  value: buttonTextVariants({
244
244
  variant,
@@ -294,7 +294,7 @@ function Icon({
294
294
  }
295
295
  }
296
296
 
297
- const _excluded$9 = ["className"];
297
+ const _excluded$b = ["className"];
298
298
  function createRNCheckboxRenderer(options = {}) {
299
299
  return createDataRenderer((props, renderer) => p => _extends({}, p, {
300
300
  label: undefined,
@@ -348,7 +348,7 @@ const RNCheckbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
348
348
  let {
349
349
  className
350
350
  } = _ref,
351
- props = _objectWithoutPropertiesLoose(_ref, _excluded$9);
351
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$b);
352
352
  return jsx(CheckboxPrimitive.Root, _extends({
353
353
  ref: ref,
354
354
  className: cn("web:peer h-4 w-4 native:h-[24px] native:w-[24px] shrink-0 rounded-sm native:rounded border border-accent web:ring-offset-background web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", className)
@@ -367,7 +367,7 @@ const RNCheckbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
367
367
  });
368
368
  RNCheckbox.displayName = CheckboxPrimitive.Root.displayName;
369
369
 
370
- const _excluded$8 = ["renderOptions", "control", "readonly"],
370
+ const _excluded$a = ["renderOptions", "control", "readonly"],
371
371
  _excluded2$5 = ["className", "placeholderClassName"];
372
372
  function createRNTextInputRenderer(inputClass, inputTextClass) {
373
373
  return createDataRenderer(p => {
@@ -376,7 +376,7 @@ function createRNTextInputRenderer(inputClass, inputTextClass) {
376
376
  control,
377
377
  readonly
378
378
  } = p,
379
- rest = _objectWithoutPropertiesLoose(p, _excluded$8);
379
+ rest = _objectWithoutPropertiesLoose(p, _excluded$a);
380
380
  const {
381
381
  disabled
382
382
  } = formControlProps(control);
@@ -423,7 +423,7 @@ function RNTextInput(_ref) {
423
423
  }
424
424
  RNTextInput.displayName = "RNInput";
425
425
 
426
- const _excluded$7 = ["control", "mode", "locale", "is24Hour", "className"];
426
+ const _excluded$9 = ["control", "mode", "locale", "is24Hour", "className"];
427
427
  function createRNDateTimePickerRenderer(options = {}) {
428
428
  return createDataRenderer(p => {
429
429
  const mode = p.field.type == FieldType.DateTime ? "datetime" : p.field.type == FieldType.Time ? "time" : "date";
@@ -447,7 +447,7 @@ function RNDateTimePicker(_ref) {
447
447
  is24Hour = true,
448
448
  className
449
449
  } = _ref,
450
- props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
450
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$9);
451
451
  const disabled = control.disabled;
452
452
  const {
453
453
  maximumDate,
@@ -517,7 +517,7 @@ function RNDateTimePicker(_ref) {
517
517
  try {
518
518
  switch (mode) {
519
519
  case "date":
520
- return parseDate(dateString).toDate(getLocalTimeZone());
520
+ return parseDate(dateString).toDate("UTC");
521
521
  case "datetime":
522
522
  return parseAbsolute(dateString, getLocalTimeZone()).toDate();
523
523
  case "time":
@@ -537,7 +537,7 @@ function RNDateTimePicker(_ref) {
537
537
  day: "2-digit",
538
538
  month: "2-digit",
539
539
  year: "numeric",
540
- timeZone: getLocalTimeZone()
540
+ timeZone: "UTC"
541
541
  };
542
542
  break;
543
543
  case "datetime":
@@ -571,36 +571,42 @@ function RNDateTimePicker(_ref) {
571
571
  }
572
572
  }
573
573
 
574
- function RNHtmlRenderer({
575
- className,
576
- html
577
- }) {
574
+ const _excluded$8 = ["className", "html", "style", "contentWidth"];
575
+ function RNHtmlRenderer(_ref) {
578
576
  var _effect = useComponentTracking();
579
577
  try {
578
+ let {
579
+ className,
580
+ html,
581
+ style,
582
+ contentWidth
583
+ } = _ref,
584
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
580
585
  if (!html) return;
581
586
  const source = {
582
587
  html: html
583
588
  };
584
589
  return jsx(View, {
590
+ style: style,
585
591
  className: className,
586
- children: jsx(RenderHtml, {
587
- contentWidth: Dimensions.get("window").width,
592
+ children: jsx(RenderHtml, _extends({
593
+ contentWidth: contentWidth != null ? contentWidth : Dimensions.get("window").width,
588
594
  source: source
589
- })
595
+ }, props))
590
596
  });
591
597
  } finally {
592
598
  _effect();
593
599
  }
594
600
  }
595
601
 
596
- const _excluded$6 = ["className", "checked", "onChange"];
602
+ const _excluded$7 = ["className", "checked", "onChange"];
597
603
  const RNRadioItem = /*#__PURE__*/React.forwardRef((_ref, ref) => {
598
604
  let {
599
605
  className,
600
606
  checked,
601
607
  onChange
602
608
  } = _ref,
603
- props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
609
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
604
610
  return jsx(Pressable, _extends({
605
611
  ref: ref,
606
612
  onPress: onChange,
@@ -631,7 +637,7 @@ function createSelectConversion(ft) {
631
637
  }
632
638
  }
633
639
 
634
- const _excluded$5 = ["state", "options", "className", "convert", "required", "emptyText", "requiredText", "portalHost", "readonly"],
640
+ const _excluded$6 = ["state", "options", "className", "convert", "required", "emptyText", "requiredText", "portalHost", "readonly"],
635
641
  _excluded2$4 = ["ref", "className", "children"],
636
642
  _excluded3$2 = ["className", "children", "position", "portalHost"],
637
643
  _excluded4$2 = ["className"],
@@ -671,7 +677,7 @@ function RNSelectRenderer(_ref) {
671
677
  portalHost,
672
678
  readonly
673
679
  } = _ref,
674
- props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
680
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
675
681
  const insets = useSafeAreaInsets();
676
682
  const contentInsets = {
677
683
  top: insets.top,
@@ -764,10 +770,11 @@ function SelectTrigger(_ref2) {
764
770
  props = _objectWithoutPropertiesLoose(_ref2, _excluded2$4);
765
771
  return jsxs(SelectPrimitive.Trigger, _extends({
766
772
  ref: ref,
767
- className: cn("flex flex-row h-10 native:h-12 items-center text-sm justify-between border border-[#E7E7E8] bg-background px-3 py-2 [&>span]:line-clamp-1 min-w-[128px]", props.disabled && "opacity-50", className)
773
+ className: cn("flex flex-row min-h-10 native:min-h-12 items-center text-sm justify-between border border-[#E7E7E8] bg-background px-3 py-2 [&>span]:line-clamp-1 min-w-[128px]", props.disabled && "opacity-50", className)
768
774
  }, props, {
769
775
  children: [jsx(Pressable, {
770
776
  pointerEvents: "none",
777
+ className: "flex-1",
771
778
  children: children
772
779
  }), jsx(Icon, {
773
780
  name: "chevron-down",
@@ -847,7 +854,7 @@ const SelectItem = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
847
854
  });
848
855
  SelectItem.displayName = SelectPrimitive.Item.displayName;
849
856
 
850
- const _excluded$4 = ["className"],
857
+ const _excluded$5 = ["className"],
851
858
  _excluded2$3 = ["className", "children"],
852
859
  _excluded3$1 = ["className", "children", "portalHost", "closeOnOutsidePress"],
853
860
  _excluded4$1 = ["className"];
@@ -861,7 +868,7 @@ function DialogOverlayWeb(_ref) {
861
868
  let {
862
869
  className
863
870
  } = _ref,
864
- props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
871
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
865
872
  const {
866
873
  open
867
874
  } = DialogPrimitive.useRootContext();
@@ -1100,6 +1107,7 @@ function RNScrollListRenderer({
1100
1107
  }
1101
1108
  }
1102
1109
 
1110
+ const _excluded$4 = ["htmlClassName"];
1103
1111
  function createDefaultDisplayRenderer(options = {}) {
1104
1112
  return {
1105
1113
  render: (props, renderer) => jsx(DefaultDisplay, {
@@ -1151,12 +1159,15 @@ function DefaultDisplay({
1151
1159
  inline: displayProps.inline
1152
1160
  });
1153
1161
  case DisplayDataType.Html:
1154
- return jsx(Div, {
1162
+ const {
1163
+ htmlClassName
1164
+ } = options,
1165
+ props = _objectWithoutPropertiesLoose(options, _excluded$4);
1166
+ return jsx(RNHtmlRenderer, _extends({
1155
1167
  style: style,
1156
- className: rendererClass(className, options.htmlClassName),
1157
- inline: displayProps.inline,
1168
+ className: rendererClass(className, htmlClassName),
1158
1169
  html: display ? coerceToString(display.value) : data.html
1159
- });
1170
+ }, props));
1160
1171
  case DisplayDataType.Custom:
1161
1172
  return jsx(Div, {
1162
1173
  children: jsxs(B, {
@@ -1302,7 +1313,7 @@ function RNCheckButtons(props) {
1302
1313
  const selOrUnsel = checked ? rendererClass(controlClasses == null ? void 0 : controlClasses.selectedClass, classes.selectedClass) : rendererClass(controlClasses == null ? void 0 : controlClasses.notSelectedClass, classes.notSelectedClass);
1303
1314
  return jsxs(Button, {
1304
1315
  className: clsx(rendererClass(controlClasses == null ? void 0 : controlClasses.entryWrapperClass, classes.entryWrapperClass), selOrUnsel),
1305
- onClick: () => !readonly && setChecked(control, o, !checked),
1316
+ onClick: () => !(readonly || disabled) && setChecked(control, o, !checked),
1306
1317
  notWrapInText: true,
1307
1318
  children: [jsxs(Div, {
1308
1319
  className: classes.entryClass,
@@ -2143,9 +2154,16 @@ function DefaultDialogRenderer({
2143
2154
  })
2144
2155
  })
2145
2156
  })]
2146
- }), allChildren.filter(x => !x.definition.placement || x.definition.placement === "dialog").map((x, i) => props.renderChild(x, {
2147
- actionOnClick
2148
- }))]
2157
+ }), jsx(ScrollView$1, {
2158
+ persistentScrollbar: true,
2159
+ children: jsx(View, {
2160
+ className: "flex flex-col gap-[12px]",
2161
+ onStartShouldSetResponder: () => true,
2162
+ children: allChildren.filter(x => !x.definition.placement || x.definition.placement === "dialog").map((x, i) => props.renderChild(x, {
2163
+ actionOnClick
2164
+ }))
2165
+ })
2166
+ })]
2149
2167
  })]
2150
2168
  });
2151
2169
  } finally {