@react-typed-forms/schemas-rn 2.0.1 → 2.2.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.
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { FormRenderer, FormStateNode, SchemaDataNode, SchemaInterface } from "@react-typed-forms/schemas";
3
- export declare function DefaultDisplayOnly({ dataNode, className, emptyText, schemaInterface, style, renderer, textClass, inline, state, }: {
3
+ export declare function DefaultDisplayOnly({ dataNode, className, emptyText, noSelection, schemaInterface, style, renderer, textClass, inline, state, }: {
4
4
  dataNode: SchemaDataNode;
5
5
  schemaInterface: SchemaInterface;
6
6
  className?: string;
@@ -9,5 +9,6 @@ export declare function DefaultDisplayOnly({ dataNode, className, emptyText, sch
9
9
  inline: boolean;
10
10
  renderer: FormRenderer;
11
11
  emptyText?: string | null;
12
+ noSelection?: boolean | null;
12
13
  state: FormStateNode;
13
14
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,8 @@
1
+ import { RenderHTMLProps } from "react-native-render-html";
2
+ import React from "react";
1
3
  export type RNHtmlRendererProps = {
2
4
  className?: string;
3
5
  html?: string;
4
- };
5
- export declare function RNHtmlRenderer({ className, html }: RNHtmlRendererProps): import("react/jsx-runtime").JSX.Element | undefined;
6
+ style?: React.CSSProperties | undefined;
7
+ } & Pick<RenderHTMLProps, "baseStyle" | "tagsStyles" | "systemFonts" | "contentWidth">;
8
+ export declare function RNHtmlRenderer({ className, html, style, contentWidth, ...props }: RNHtmlRendererProps): import("react/jsx-runtime").JSX.Element | undefined;
@@ -1,8 +1,11 @@
1
- import { HtmlComponents } from "@react-typed-forms/schemas";
1
+ import { HtmlDivProperties, HtmlComponents } from "@react-typed-forms/schemas";
2
2
  import { AdornmentRendererRegistration, DataRendererRegistration, DefaultRenderers, LabelRendererRegistration } from "@react-typed-forms/schemas";
3
3
  import { DefaultRendererOptions, DefaultDataRendererOptions, DefaultLabelRendererOptions, DefaultAdornmentRendererOptions } from "./rendererOptions";
4
4
  export declare function createDefaultDataRenderer(options?: DefaultDataRendererOptions): DataRendererRegistration;
5
5
  export declare function createDefaultAdornmentRenderer(options?: DefaultAdornmentRendererOptions): AdornmentRendererRegistration;
6
6
  export declare function createDefaultLabelRenderer(options?: DefaultLabelRendererOptions): LabelRendererRegistration;
7
+ export declare function RNDiv({ className, html, children, textClass, text, style, inline, role, noSelection, ...props }: HtmlDivProperties & {
8
+ noSelection?: boolean | null;
9
+ }): import("react/jsx-runtime").JSX.Element;
7
10
  export declare const ReactNativeHtmlComponents: HtmlComponents;
8
11
  export declare function createDefaultRenderers(options?: DefaultRendererOptions): DefaultRenderers;
package/lib/index.cjs CHANGED
@@ -205,13 +205,13 @@ function cn() {
205
205
  return tailwindMerge.twMerge(clsx.clsx([].slice.call(arguments)));
206
206
  }
207
207
 
208
- var _excluded$b = ["className", "asChild"];
208
+ var _excluded$d = ["className", "asChild"];
209
209
  var TextClassContext = /*#__PURE__*/React__namespace.createContext(undefined);
210
210
  var RNText = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
211
211
  var className = _ref.className,
212
212
  _ref$asChild = _ref.asChild,
213
213
  asChild = _ref$asChild === void 0 ? false : _ref$asChild,
214
- props = _objectWithoutPropertiesLoose(_ref, _excluded$b);
214
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
215
215
  var textClass = React__namespace.useContext(TextClassContext);
216
216
  var Component = asChild ? Slot__namespace.Text : reactNative.Text;
217
217
  return jsxRuntime.jsx(Component, _extends({
@@ -221,7 +221,7 @@ var RNText = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
221
221
  });
222
222
  RNText.displayName = "RNText";
223
223
 
224
- var _excluded$a = ["className", "variant", "size"];
224
+ var _excluded$c = ["className", "variant", "size"];
225
225
  var buttonVariants = classVarianceAuthority.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", {
226
226
  variants: {
227
227
  variant: {
@@ -270,7 +270,7 @@ var RNButton$1 = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
270
270
  var className = _ref.className,
271
271
  variant = _ref.variant,
272
272
  size = _ref.size,
273
- props = _objectWithoutPropertiesLoose(_ref, _excluded$a);
273
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
274
274
  return jsxRuntime.jsx(TextClassContext.Provider, {
275
275
  value: buttonTextVariants({
276
276
  variant: variant,
@@ -326,7 +326,7 @@ function Icon(_ref) {
326
326
  }
327
327
  }
328
328
 
329
- var _excluded$9 = ["className"];
329
+ var _excluded$b = ["className"];
330
330
  function createRNCheckboxRenderer(options) {
331
331
  if (options === void 0) {
332
332
  options = {};
@@ -382,7 +382,7 @@ function CheckBoxRenderer(_ref) {
382
382
  }
383
383
  var RNCheckbox = /*#__PURE__*/React__namespace.forwardRef(function (_ref2, ref) {
384
384
  var className = _ref2.className,
385
- props = _objectWithoutPropertiesLoose(_ref2, _excluded$9);
385
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded$b);
386
386
  return jsxRuntime.jsx(CheckboxPrimitive__namespace.Root, _extends({
387
387
  ref: ref,
388
388
  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)
@@ -401,14 +401,14 @@ var RNCheckbox = /*#__PURE__*/React__namespace.forwardRef(function (_ref2, ref)
401
401
  });
402
402
  RNCheckbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
403
403
 
404
- var _excluded$8 = ["renderOptions", "control", "readonly"],
404
+ var _excluded$a = ["renderOptions", "control", "readonly"],
405
405
  _excluded2$5 = ["className", "placeholderClassName"];
406
406
  function createRNTextInputRenderer(inputClass, inputTextClass) {
407
407
  return schemas.createDataRenderer(function (p) {
408
408
  var renderOptions = p.renderOptions,
409
409
  control = p.control,
410
410
  readonly = p.readonly,
411
- rest = _objectWithoutPropertiesLoose(p, _excluded$8);
411
+ rest = _objectWithoutPropertiesLoose(p, _excluded$a);
412
412
  var _formControlProps = core.formControlProps(control),
413
413
  disabled = _formControlProps.disabled;
414
414
  var placeholder = renderOptions.placeholder,
@@ -452,7 +452,7 @@ function RNTextInput(_ref) {
452
452
  }
453
453
  RNTextInput.displayName = "RNInput";
454
454
 
455
- var _excluded$7 = ["control", "mode", "locale", "is24Hour", "className"];
455
+ var _excluded$9 = ["control", "mode", "locale", "is24Hour", "className"];
456
456
  function createRNDateTimePickerRenderer(options) {
457
457
  if (options === void 0) {
458
458
  options = {};
@@ -538,7 +538,7 @@ function RNDateTimePicker(_ref) {
538
538
  _ref$is24Hour = _ref.is24Hour,
539
539
  is24Hour = _ref$is24Hour === void 0 ? true : _ref$is24Hour,
540
540
  className = _ref.className,
541
- props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
541
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$9);
542
542
  var disabled = control.disabled;
543
543
  var maximumDate = props.maximumDate,
544
544
  minimumDate = props.minimumDate;
@@ -601,33 +601,41 @@ function RNDateTimePicker(_ref) {
601
601
  }
602
602
  }
603
603
 
604
+ var _excluded$8 = ["className", "html", "style", "contentWidth"];
604
605
  function RNHtmlRenderer(_ref) {
605
606
  var _effect = core.useComponentTracking();
606
607
  try {
607
608
  var className = _ref.className,
608
- html = _ref.html;
609
+ html = _ref.html,
610
+ style = _ref.style,
611
+ contentWidth = _ref.contentWidth,
612
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
609
613
  if (!html) return;
610
614
  var source = {
611
615
  html: html
612
616
  };
613
617
  return jsxRuntime.jsx(reactNative.View, {
618
+ style: style,
614
619
  className: className,
615
- children: jsxRuntime.jsx(RenderHtml__default["default"], {
616
- contentWidth: reactNative.Dimensions.get("window").width,
620
+ children: jsxRuntime.jsx(RenderHtml__default["default"], _extends({
621
+ defaultTextProps: {
622
+ selectable: true
623
+ },
624
+ contentWidth: contentWidth != null ? contentWidth : reactNative.Dimensions.get("window").width,
617
625
  source: source
618
- })
626
+ }, props))
619
627
  });
620
628
  } finally {
621
629
  _effect();
622
630
  }
623
631
  }
624
632
 
625
- var _excluded$6 = ["className", "checked", "onChange"];
633
+ var _excluded$7 = ["className", "checked", "onChange"];
626
634
  var RNRadioItem = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
627
635
  var className = _ref.className,
628
636
  checked = _ref.checked,
629
637
  onChange = _ref.onChange,
630
- props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
638
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
631
639
  return jsxRuntime.jsx(reactNative.Pressable, _extends({
632
640
  ref: ref,
633
641
  onPress: onChange,
@@ -660,7 +668,7 @@ function createSelectConversion(ft) {
660
668
  }
661
669
  }
662
670
 
663
- var _excluded$5 = ["state", "options", "className", "convert", "required", "emptyText", "requiredText", "portalHost", "readonly"],
671
+ var _excluded$6 = ["state", "options", "className", "convert", "required", "emptyText", "requiredText", "portalHost", "readonly"],
664
672
  _excluded2$4 = ["ref", "className", "children"],
665
673
  _excluded3$2 = ["className", "children", "position", "portalHost"],
666
674
  _excluded4$2 = ["className"],
@@ -711,7 +719,7 @@ function RNSelectRenderer(_ref) {
711
719
  requiredText = _ref$requiredText === void 0 ? "Please select" : _ref$requiredText,
712
720
  portalHost = _ref.portalHost,
713
721
  readonly = _ref.readonly,
714
- props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
722
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
715
723
  var insets = reactNativeSafeAreaContext.useSafeAreaInsets();
716
724
  var contentInsets = {
717
725
  top: insets.top,
@@ -891,7 +899,7 @@ var SelectItem = /*#__PURE__*/React__namespace.forwardRef(function (_ref5, ref)
891
899
  });
892
900
  SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
893
901
 
894
- var _excluded$4 = ["className"],
902
+ var _excluded$5 = ["className"],
895
903
  _excluded2$3 = ["className", "children"],
896
904
  _excluded3$1 = ["className", "children", "portalHost", "closeOnOutsidePress"],
897
905
  _excluded4$1 = ["className"];
@@ -903,7 +911,7 @@ function DialogOverlayWeb(_ref) {
903
911
  var _effect = core.useComponentTracking();
904
912
  try {
905
913
  var className = _ref.className,
906
- props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
914
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
907
915
  var _DialogPrimitive$useR = DialogPrimitive__namespace.useRootContext(),
908
916
  open = _DialogPrimitive$useR.open;
909
917
  return jsxRuntime.jsx(DialogPrimitive__namespace.Overlay, _extends({
@@ -1139,6 +1147,7 @@ function RNScrollListRenderer(_ref) {
1139
1147
  }
1140
1148
  }
1141
1149
 
1150
+ var _excluded$4 = ["htmlClassName"];
1142
1151
  function createDefaultDisplayRenderer(options) {
1143
1152
  if (options === void 0) {
1144
1153
  options = {};
@@ -1191,12 +1200,13 @@ function DefaultDisplay(_ref) {
1191
1200
  inline: displayProps.inline
1192
1201
  });
1193
1202
  case schemas.DisplayDataType.Html:
1194
- return jsxRuntime.jsx(Div, {
1203
+ var htmlClassName = options.htmlClassName,
1204
+ props = _objectWithoutPropertiesLoose(options, _excluded$4);
1205
+ return jsxRuntime.jsx(RNHtmlRenderer, _extends({
1195
1206
  style: style,
1196
- className: schemas.rendererClass(className, options.htmlClassName),
1197
- inline: displayProps.inline,
1207
+ className: schemas.rendererClass(className, htmlClassName),
1198
1208
  html: display ? schemas.coerceToString(display.value) : data.html
1199
- });
1209
+ }, props));
1200
1210
  case schemas.DisplayDataType.Custom:
1201
1211
  return jsxRuntime.jsx(Div, {
1202
1212
  children: jsxRuntime.jsxs(B, {
@@ -1386,6 +1396,7 @@ function DefaultDisplayOnly(_ref) {
1386
1396
  var dataNode = _ref.dataNode,
1387
1397
  className = _ref.className,
1388
1398
  emptyText = _ref.emptyText,
1399
+ noSelection = _ref.noSelection,
1389
1400
  schemaInterface = _ref.schemaInterface,
1390
1401
  style = _ref.style,
1391
1402
  renderer = _ref.renderer,
@@ -1394,13 +1405,13 @@ function DefaultDisplayOnly(_ref) {
1394
1405
  state = _ref.state;
1395
1406
  var display = state.resolved.display;
1396
1407
  var text = display != null ? display : (_ref2 = schemaInterface.isEmptyValue(dataNode.schema.field, dataNode.control.value) ? emptyText : schemaInterface.textValueForData(dataNode)) != null ? _ref2 : "";
1397
- var Div = renderer.html.Div;
1398
- return jsxRuntime.jsx(Div, {
1408
+ return jsxRuntime.jsx(RNDiv, {
1399
1409
  style: style,
1400
1410
  className: className,
1401
1411
  textClass: textClass,
1402
1412
  text: text,
1403
- inline: inline
1413
+ inline: inline,
1414
+ noSelection: noSelection
1404
1415
  });
1405
1416
  } finally {
1406
1417
  _effect();
@@ -2447,7 +2458,7 @@ function createButtonActionRenderer(actionId, options) {
2447
2458
 
2448
2459
  var _excluded = ["inline", "textClass", "children", "notWrapInText", "androidRippleColor", "nonTextContent", "onClick"],
2449
2460
  _excluded2 = ["className", "html", "children", "textClass", "text", "style", "inline", "role"],
2450
- _excluded3 = ["className", "html", "children", "textClass", "text", "style", "inline", "role"],
2461
+ _excluded3 = ["className", "html", "children", "textClass", "text", "style", "inline", "role", "noSelection"],
2451
2462
  _excluded4 = ["id", "type", "onChangeValue", "onChangeChecked", "checked", "value"];
2452
2463
  function createDefaultDataRenderer(options) {
2453
2464
  var _options$checkboxOpti, _options$checkboxOpti2, _options$radioOptions, _options$checkListOpt;
@@ -2506,7 +2517,8 @@ function createDefaultDataRenderer(options) {
2506
2517
  style: props.style,
2507
2518
  inline: props.inline,
2508
2519
  renderer: renderers,
2509
- emptyText: schemas.isDisplayOnlyRenderer(renderOptions) && renderOptions.emptyText ? renderOptions.emptyText : defaultEmptyText
2520
+ emptyText: schemas.isDisplayOnlyRenderer(renderOptions) && renderOptions.emptyText ? renderOptions.emptyText : defaultEmptyText,
2521
+ noSelection: schemas.isDisplayOnlyRenderer(renderOptions) ? renderOptions.noSelection : undefined
2510
2522
  })
2511
2523
  });
2512
2524
  };
@@ -2795,6 +2807,7 @@ function RNDiv(_ref8) {
2795
2807
  style = _ref8.style,
2796
2808
  inline = _ref8.inline,
2797
2809
  role = _ref8.role,
2810
+ noSelection = _ref8.noSelection,
2798
2811
  props = _objectWithoutPropertiesLoose(_ref8, _excluded3);
2799
2812
  if (html != null) {
2800
2813
  return jsxRuntime.jsx(RNHtmlRenderer, _extends({}, props, {
@@ -2805,6 +2818,7 @@ function RNDiv(_ref8) {
2805
2818
  return jsxRuntime.jsx(reactNative.Text, {
2806
2819
  style: style,
2807
2820
  className: textClass,
2821
+ selectable: !noSelection,
2808
2822
  children: text != null ? text : children
2809
2823
  });
2810
2824
  }
@@ -2816,6 +2830,7 @@ function RNDiv(_ref8) {
2816
2830
  }, props, {
2817
2831
  children: jsxRuntime.jsx(reactNative.Text, {
2818
2832
  className: textClass,
2833
+ selectable: !noSelection,
2819
2834
  children: text
2820
2835
  })
2821
2836
  }));
@@ -2928,6 +2943,7 @@ exports.Icon = Icon;
2928
2943
  exports.RNButton = RNButton$1;
2929
2944
  exports.RNCheckbox = RNCheckbox;
2930
2945
  exports.RNDialog = RNDialog;
2946
+ exports.RNDiv = RNDiv;
2931
2947
  exports.RNHtmlRenderer = RNHtmlRenderer;
2932
2948
  exports.RNRadioItem = RNRadioItem;
2933
2949
  exports.RNSelectRenderer = RNSelectRenderer;