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

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;
@@ -4,5 +4,6 @@ export type RNHtmlRendererProps = {
4
4
  className?: string;
5
5
  html?: string;
6
6
  style?: React.CSSProperties | undefined;
7
+ noSelection?: boolean | null;
7
8
  } & Pick<RenderHTMLProps, "baseStyle" | "tagsStyles" | "systemFonts" | "contentWidth">;
8
- export declare function RNHtmlRenderer({ className, html, style, contentWidth, ...props }: RNHtmlRendererProps): import("react/jsx-runtime").JSX.Element | undefined;
9
+ export declare function RNHtmlRenderer({ className, html, style, contentWidth, noSelection, ...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
@@ -601,7 +601,7 @@ function RNDateTimePicker(_ref) {
601
601
  }
602
602
  }
603
603
 
604
- var _excluded$8 = ["className", "html", "style", "contentWidth"];
604
+ var _excluded$8 = ["className", "html", "style", "contentWidth", "noSelection"];
605
605
  function RNHtmlRenderer(_ref) {
606
606
  var _effect = core.useComponentTracking();
607
607
  try {
@@ -609,6 +609,7 @@ function RNHtmlRenderer(_ref) {
609
609
  html = _ref.html,
610
610
  style = _ref.style,
611
611
  contentWidth = _ref.contentWidth,
612
+ noSelection = _ref.noSelection,
612
613
  props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
613
614
  if (!html) return;
614
615
  var source = {
@@ -618,6 +619,9 @@ function RNHtmlRenderer(_ref) {
618
619
  style: style,
619
620
  className: className,
620
621
  children: jsxRuntime.jsx(RenderHtml__default["default"], _extends({
622
+ defaultTextProps: {
623
+ selectable: !noSelection
624
+ },
621
625
  contentWidth: contentWidth != null ? contentWidth : reactNative.Dimensions.get("window").width,
622
626
  source: source
623
627
  }, props))
@@ -1189,12 +1193,13 @@ function DefaultDisplay(_ref) {
1189
1193
  });
1190
1194
  case schemas.DisplayDataType.Text:
1191
1195
  var text = display ? schemas.coerceToString(display.value) : data.text;
1192
- return jsxRuntime.jsx(Div, {
1196
+ return jsxRuntime.jsx(RNDiv, {
1193
1197
  style: style,
1194
1198
  className: schemas.rendererClass(className, options.textClassName),
1195
1199
  textClass: schemas.rendererClass(textClass, options.textTextClass),
1196
1200
  text: text,
1197
- inline: displayProps.inline
1201
+ inline: displayProps.inline,
1202
+ noSelection: displayProps.noSelection
1198
1203
  });
1199
1204
  case schemas.DisplayDataType.Html:
1200
1205
  var htmlClassName = options.htmlClassName,
@@ -1202,6 +1207,7 @@ function DefaultDisplay(_ref) {
1202
1207
  return jsxRuntime.jsx(RNHtmlRenderer, _extends({
1203
1208
  style: style,
1204
1209
  className: schemas.rendererClass(className, htmlClassName),
1210
+ noSelection: displayProps.noSelection,
1205
1211
  html: display ? schemas.coerceToString(display.value) : data.html
1206
1212
  }, props));
1207
1213
  case schemas.DisplayDataType.Custom:
@@ -1393,6 +1399,7 @@ function DefaultDisplayOnly(_ref) {
1393
1399
  var dataNode = _ref.dataNode,
1394
1400
  className = _ref.className,
1395
1401
  emptyText = _ref.emptyText,
1402
+ noSelection = _ref.noSelection,
1396
1403
  schemaInterface = _ref.schemaInterface,
1397
1404
  style = _ref.style,
1398
1405
  renderer = _ref.renderer,
@@ -1401,13 +1408,13 @@ function DefaultDisplayOnly(_ref) {
1401
1408
  state = _ref.state;
1402
1409
  var display = state.resolved.display;
1403
1410
  var text = display != null ? display : (_ref2 = schemaInterface.isEmptyValue(dataNode.schema.field, dataNode.control.value) ? emptyText : schemaInterface.textValueForData(dataNode)) != null ? _ref2 : "";
1404
- var Div = renderer.html.Div;
1405
- return jsxRuntime.jsx(Div, {
1411
+ return jsxRuntime.jsx(RNDiv, {
1406
1412
  style: style,
1407
1413
  className: className,
1408
1414
  textClass: textClass,
1409
1415
  text: text,
1410
- inline: inline
1416
+ inline: inline,
1417
+ noSelection: noSelection
1411
1418
  });
1412
1419
  } finally {
1413
1420
  _effect();
@@ -2454,7 +2461,7 @@ function createButtonActionRenderer(actionId, options) {
2454
2461
 
2455
2462
  var _excluded = ["inline", "textClass", "children", "notWrapInText", "androidRippleColor", "nonTextContent", "onClick"],
2456
2463
  _excluded2 = ["className", "html", "children", "textClass", "text", "style", "inline", "role"],
2457
- _excluded3 = ["className", "html", "children", "textClass", "text", "style", "inline", "role"],
2464
+ _excluded3 = ["className", "html", "children", "textClass", "text", "style", "inline", "role", "noSelection"],
2458
2465
  _excluded4 = ["id", "type", "onChangeValue", "onChangeChecked", "checked", "value"];
2459
2466
  function createDefaultDataRenderer(options) {
2460
2467
  var _options$checkboxOpti, _options$checkboxOpti2, _options$radioOptions, _options$checkListOpt;
@@ -2513,7 +2520,8 @@ function createDefaultDataRenderer(options) {
2513
2520
  style: props.style,
2514
2521
  inline: props.inline,
2515
2522
  renderer: renderers,
2516
- emptyText: schemas.isDisplayOnlyRenderer(renderOptions) && renderOptions.emptyText ? renderOptions.emptyText : defaultEmptyText
2523
+ emptyText: schemas.isDisplayOnlyRenderer(renderOptions) && renderOptions.emptyText ? renderOptions.emptyText : defaultEmptyText,
2524
+ noSelection: props.definition.noSelection
2517
2525
  })
2518
2526
  });
2519
2527
  };
@@ -2802,16 +2810,19 @@ function RNDiv(_ref8) {
2802
2810
  style = _ref8.style,
2803
2811
  inline = _ref8.inline,
2804
2812
  role = _ref8.role,
2813
+ noSelection = _ref8.noSelection,
2805
2814
  props = _objectWithoutPropertiesLoose(_ref8, _excluded3);
2806
2815
  if (html != null) {
2807
2816
  return jsxRuntime.jsx(RNHtmlRenderer, _extends({}, props, {
2808
- html: html
2817
+ html: html,
2818
+ noSelection: noSelection
2809
2819
  }));
2810
2820
  }
2811
2821
  if (inline) {
2812
2822
  return jsxRuntime.jsx(reactNative.Text, {
2813
2823
  style: style,
2814
2824
  className: textClass,
2825
+ selectable: !noSelection,
2815
2826
  children: text != null ? text : children
2816
2827
  });
2817
2828
  }
@@ -2823,6 +2834,7 @@ function RNDiv(_ref8) {
2823
2834
  }, props, {
2824
2835
  children: jsxRuntime.jsx(reactNative.Text, {
2825
2836
  className: textClass,
2837
+ selectable: !noSelection,
2826
2838
  children: text
2827
2839
  })
2828
2840
  }));
@@ -2935,6 +2947,7 @@ exports.Icon = Icon;
2935
2947
  exports.RNButton = RNButton$1;
2936
2948
  exports.RNCheckbox = RNCheckbox;
2937
2949
  exports.RNDialog = RNDialog;
2950
+ exports.RNDiv = RNDiv;
2938
2951
  exports.RNHtmlRenderer = RNHtmlRenderer;
2939
2952
  exports.RNRadioItem = RNRadioItem;
2940
2953
  exports.RNSelectRenderer = RNSelectRenderer;