@digigov/react-core 1.2.0-mobile → 1.2.0-mobile-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.
Files changed (117) hide show
  1. package/Base/compat/Input/CheckboxInput/index.js +2 -17
  2. package/Base/compat/Input/CheckboxInput.js.map +2 -2
  3. package/Base/compat/Input/RadioInput/index.js +5 -21
  4. package/Base/compat/Input/RadioInput.js.map +2 -2
  5. package/Base/compat/Input/StringInput/index.js +3 -2
  6. package/Base/compat/Input/StringInput.js.map +2 -2
  7. package/Base/compat/button/index.js +25 -0
  8. package/Base/compat/button/package.json +6 -0
  9. package/Base/compat/button.js.map +7 -0
  10. package/Base/index.native/index.js +6 -40
  11. package/Base/index.native.js.map +3 -3
  12. package/Base/mapping/index.js +4 -16
  13. package/Base/mapping.js.map +2 -2
  14. package/Base/utils/index.js +52 -1
  15. package/Base/utils.d.ts +2 -0
  16. package/Base/utils.js.map +3 -3
  17. package/CheckboxItem/index.js +2 -15
  18. package/CheckboxItem/index.js.map +2 -2
  19. package/CheckboxItemInput/index.d.ts +2 -0
  20. package/CheckboxItemInput/index.js +6 -0
  21. package/CheckboxItemInput/index.js.map +7 -0
  22. package/CheckboxItemInput/index.native/index.js +15 -0
  23. package/CheckboxItemInput/index.native/package.json +6 -0
  24. package/CheckboxItemInput/index.native.d.ts +5 -0
  25. package/CheckboxItemInput/index.native.js.map +7 -0
  26. package/CheckboxItemInput/index.web/index.js +26 -0
  27. package/CheckboxItemInput/index.web/package.json +6 -0
  28. package/CheckboxItemInput/index.web.d.ts +10 -0
  29. package/CheckboxItemInput/index.web.js.map +7 -0
  30. package/CheckboxItemInput/package.json +6 -0
  31. package/CopyToClipboardContainer/index.d.ts +2 -31
  32. package/CopyToClipboardContainer/index.js +3 -40
  33. package/CopyToClipboardContainer/index.js.map +3 -3
  34. package/CopyToClipboardContainer/index.web/index.js +44 -0
  35. package/CopyToClipboardContainer/index.web/package.json +6 -0
  36. package/CopyToClipboardContainer/index.web.d.ts +31 -0
  37. package/CopyToClipboardContainer/index.web.js.map +7 -0
  38. package/CopyToClipboardMessage/index.d.ts +2 -18
  39. package/CopyToClipboardMessage/index.js +3 -21
  40. package/CopyToClipboardMessage/index.js.map +3 -3
  41. package/CopyToClipboardMessage/index.native/index.js +21 -0
  42. package/CopyToClipboardMessage/index.native/package.json +6 -0
  43. package/CopyToClipboardMessage/index.native.d.ts +7 -0
  44. package/CopyToClipboardMessage/index.native.js.map +7 -0
  45. package/CopyToClipboardMessage/index.web/index.js +24 -0
  46. package/CopyToClipboardMessage/index.web/package.json +6 -0
  47. package/CopyToClipboardMessage/index.web.d.ts +18 -0
  48. package/CopyToClipboardMessage/index.web.js.map +7 -0
  49. package/TextInput/index.d.ts +2 -46
  50. package/TextInput/index.js +3 -40
  51. package/TextInput/index.js.map +3 -3
  52. package/TextInput/index.native/index.js +15 -0
  53. package/TextInput/index.native/package.json +6 -0
  54. package/TextInput/index.native.d.ts +5 -0
  55. package/TextInput/index.native.js.map +7 -0
  56. package/TextInput/index.web/index.js +43 -0
  57. package/TextInput/index.web/package.json +6 -0
  58. package/TextInput/index.web.d.ts +46 -0
  59. package/TextInput/index.web.js.map +7 -0
  60. package/cjs/Base/compat/Input/CheckboxInput/index.js +1 -16
  61. package/cjs/Base/compat/Input/CheckboxInput.js.map +2 -2
  62. package/cjs/Base/compat/Input/RadioInput/index.js +4 -20
  63. package/cjs/Base/compat/Input/RadioInput.js.map +2 -2
  64. package/cjs/Base/compat/Input/StringInput/index.js +3 -2
  65. package/cjs/Base/compat/Input/StringInput.js.map +2 -2
  66. package/cjs/Base/compat/button/index.js +60 -0
  67. package/cjs/Base/compat/button.js.map +7 -0
  68. package/cjs/Base/index.native/index.js +5 -39
  69. package/cjs/Base/index.native.js.map +3 -3
  70. package/cjs/Base/mapping/index.js +2 -14
  71. package/cjs/Base/mapping.js.map +3 -3
  72. package/cjs/Base/utils/index.js +54 -2
  73. package/cjs/Base/utils.js.map +4 -4
  74. package/cjs/CheckboxItem/index.js +2 -15
  75. package/cjs/CheckboxItem/index.js.map +3 -3
  76. package/cjs/CheckboxItemInput/index.js +40 -0
  77. package/cjs/CheckboxItemInput/index.js.map +7 -0
  78. package/cjs/CheckboxItemInput/index.native/index.js +48 -0
  79. package/cjs/CheckboxItemInput/index.native.js.map +7 -0
  80. package/cjs/CheckboxItemInput/index.web/index.js +59 -0
  81. package/cjs/CheckboxItemInput/index.web.js.map +7 -0
  82. package/cjs/CopyToClipboardContainer/index.js +5 -41
  83. package/cjs/CopyToClipboardContainer/index.js.map +3 -3
  84. package/cjs/CopyToClipboardContainer/index.web/index.js +77 -0
  85. package/cjs/CopyToClipboardContainer/index.web.js.map +7 -0
  86. package/cjs/CopyToClipboardMessage/index.js +5 -22
  87. package/cjs/CopyToClipboardMessage/index.js.map +3 -3
  88. package/cjs/CopyToClipboardMessage/index.native/index.js +54 -0
  89. package/cjs/CopyToClipboardMessage/index.native.js.map +7 -0
  90. package/cjs/CopyToClipboardMessage/index.web/index.js +57 -0
  91. package/cjs/CopyToClipboardMessage/index.web.js.map +7 -0
  92. package/cjs/TextInput/index.js +5 -41
  93. package/cjs/TextInput/index.js.map +3 -3
  94. package/cjs/TextInput/index.native/index.js +48 -0
  95. package/cjs/TextInput/index.native.js.map +7 -0
  96. package/cjs/TextInput/index.web/index.js +76 -0
  97. package/cjs/TextInput/index.web.js.map +7 -0
  98. package/package.json +4 -2
  99. package/src/Base/compat/Input/CheckboxInput.tsx +6 -22
  100. package/src/Base/compat/Input/RadioInput.tsx +6 -25
  101. package/src/Base/compat/Input/StringInput.tsx +12 -5
  102. package/src/Base/compat/button.tsx +21 -0
  103. package/src/Base/index.native.tsx +132 -155
  104. package/src/Base/mapping.tsx +3 -14
  105. package/src/Base/{utils.ts → utils.tsx} +63 -1
  106. package/src/CheckboxItem/index.tsx +2 -12
  107. package/src/CheckboxItemInput/index.native.tsx +10 -0
  108. package/src/CheckboxItemInput/index.tsx +2 -0
  109. package/src/CheckboxItemInput/index.web.tsx +34 -0
  110. package/src/CopyToClipboardContainer/index.tsx +2 -74
  111. package/src/CopyToClipboardContainer/index.web.tsx +75 -0
  112. package/src/CopyToClipboardMessage/index.native.tsx +24 -0
  113. package/src/CopyToClipboardMessage/index.tsx +2 -41
  114. package/src/CopyToClipboardMessage/index.web.tsx +41 -0
  115. package/src/TextInput/index.native.tsx +10 -0
  116. package/src/TextInput/index.tsx +2 -87
  117. package/src/TextInput/index.web.tsx +87 -0
@@ -0,0 +1,48 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var index_native_exports = {};
29
+ __export(index_native_exports, {
30
+ TextInput: () => TextInput,
31
+ default: () => index_native_default
32
+ });
33
+ module.exports = __toCommonJS(index_native_exports);
34
+ var import_extend = __toESM(require("@digigov/react-core/utils/extend"));
35
+ var import_TextInput = __toESM(require("@digigov/react-core/TextInput/index.web"));
36
+ var import_clsx = __toESM(require("clsx"));
37
+ const TextInput = (0, import_extend.default)(import_TextInput.default, ({ className, ...props }) => ({
38
+ ...props,
39
+ className: (0, import_clsx.default)(className, {
40
+ "ds-input__wrapper": true
41
+ })
42
+ }));
43
+ var index_native_default = TextInput;
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ TextInput
47
+ });
48
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/TextInput/index.native.tsx"],
4
+ "sourcesContent": ["import extend from '@digigov/react-core/utils/extend';\nimport CoreTextInput from '@digigov/react-core/TextInput/index.web';\nimport clsx from 'clsx';\nexport const TextInput = extend(CoreTextInput, ({ className, ...props }) => ({\n ...props,\n className: clsx(className, {\n 'ds-input__wrapper': true\n })\n}))\nexport default TextInput;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,uBAA0B;AAC1B,kBAAiB;AACV,MAAM,gBAAY,cAAAA,SAAO,iBAAAC,SAAe,CAAC,EAAE,WAAW,GAAG,MAAM,OAAO;AAAA,EACzE,GAAG;AAAA,EACH,eAAW,YAAAC,SAAK,WAAW;AAAA,IACvB,qBAAqB;AAAA,EACzB,CAAC;AACL,EAAE;AACF,IAAO,uBAAQ;",
6
+ "names": ["extend", "CoreTextInput", "clsx"]
7
+ }
@@ -0,0 +1,76 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var index_web_exports = {};
29
+ __export(index_web_exports, {
30
+ TextInput: () => TextInput,
31
+ default: () => index_web_default
32
+ });
33
+ module.exports = __toCommonJS(index_web_exports);
34
+ var import_react = __toESM(require("react"));
35
+ var import_clsx = __toESM(require("clsx"));
36
+ var import_Base = __toESM(require("@digigov/react-core/Base"));
37
+ const TextInput = import_react.default.forwardRef(
38
+ function TextInput2({
39
+ type = "text",
40
+ maxWidth,
41
+ width,
42
+ error,
43
+ dense,
44
+ className,
45
+ children,
46
+ ...props
47
+ }, ref) {
48
+ return /* @__PURE__ */ import_react.default.createElement(
49
+ import_Base.default,
50
+ {
51
+ as: "input",
52
+ type,
53
+ ref,
54
+ className: (0, import_clsx.default)(className, {
55
+ "ds-input": true,
56
+ "ds-input--error": error,
57
+ "ds-input--dense": dense,
58
+ [`ds-input--width-${maxWidth}`]: maxWidth !== void 0,
59
+ "ds-!-width-one-quarter": width === "25%",
60
+ "ds-!-width-one-third": width === "33.3%",
61
+ "ds-!-width-one-half": width === "50%",
62
+ "ds-!-width-two-thirds": width === "66.6%",
63
+ "ds-!-width-three-quarters": width === "75%"
64
+ }),
65
+ ...props
66
+ },
67
+ children
68
+ );
69
+ }
70
+ );
71
+ var index_web_default = TextInput;
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ TextInput
75
+ });
76
+ //# sourceMappingURL=index.web.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/TextInput/index.web.tsx"],
4
+ "sourcesContent": ["import React from 'react';\nimport clsx from 'clsx';\nimport Base, { BaseProps } from '@digigov/react-core/Base';\n\nexport interface TextInputProps extends BaseProps<'input'> {\n /**\n * maxWidth is optional.\n * @value '2-char';\n * @value '3-char';\n * @value '4-char';\n * @value '5-char';\n * @value '10-char';\n * @value '20-char';\n */\n maxWidth?: '2-char' | '3-char' | '4-char' | '5-char' | '10-char' | '20-char';\n\n /**\n * width is optional.\n * Use width prop to define a custom width in your component.\n * @value '25%';\n * @value '33.3%';\n * @value '50%';\n * @value '66.6%';\n * @value '75%';\n * @value '100%';\n * @value 'full';\n */\n width?: '25%' | '33.3%' | '50%' | '66.6%' | '75%' | '100%' | 'full';\n\n /**\n * error is optional. The default value is false.\n * Use this prop when there is an error at the input.\n * @value true\n * @value false\n */\n error?: boolean;\n /**\n * dense is optional.\n * @value true TextInput will be dense.\n * @value false\n * @default false\n */\n dense?: boolean;\n}\n/**\n * TextInput component when you need to let users enter text that\u2019s no\n * longer than a single line, such as their name or phone number.\n */\nexport const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(\n function TextInput(\n {\n type = 'text',\n maxWidth,\n width,\n error,\n dense,\n className,\n children,\n ...props\n },\n ref\n ) {\n return (\n <Base\n as=\"input\"\n type={type}\n ref={ref}\n className={clsx(className, {\n 'ds-input': true,\n 'ds-input--error': error,\n 'ds-input--dense': dense,\n [`ds-input--width-${maxWidth}`]: maxWidth !== undefined,\n 'ds-!-width-one-quarter': width === '25%',\n 'ds-!-width-one-third': width === '33.3%',\n 'ds-!-width-one-half': width === '50%',\n 'ds-!-width-two-thirds': width === '66.6%',\n 'ds-!-width-three-quarters': width === '75%',\n })}\n {...props}\n >\n {children}\n </Base>\n );\n }\n);\n\nexport default TextInput;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,kBAAiB;AACjB,kBAAgC;AA8CzB,MAAM,YAAY,aAAAA,QAAM;AAAA,EAC7B,SAASC,WACP;AAAA,IACE,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,KACA;AACA,WACE,6BAAAD,QAAA;AAAA,MAAC,YAAAE;AAAA,MAAA;AAAA,QACC,IAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,eAAW,YAAAC,SAAK,WAAW;AAAA,UACzB,YAAY;AAAA,UACZ,mBAAmB;AAAA,UACnB,mBAAmB;AAAA,UACnB,CAAC,mBAAmB,QAAQ,EAAE,GAAG,aAAa;AAAA,UAC9C,0BAA0B,UAAU;AAAA,UACpC,wBAAwB,UAAU;AAAA,UAClC,uBAAuB,UAAU;AAAA,UACjC,yBAAyB,UAAU;AAAA,UACnC,6BAA6B,UAAU;AAAA,QACzC,CAAC;AAAA,QACA,GAAG;AAAA;AAAA,MAEH;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,IAAO,oBAAQ;",
6
+ "names": ["React", "TextInput", "Base", "clsx"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digigov/react-core",
3
- "version": "1.2.0-mobile",
3
+ "version": "1.2.0-mobile-1",
4
4
  "description": "@digigov react core components",
5
5
  "author": "GRNET Developers <devs@lists.grnet.gr>",
6
6
  "license": "BSD-2-Clause",
@@ -10,7 +10,9 @@
10
10
  "@digigov/react-icons": "1.1.2",
11
11
  "clsx": "1.1.1",
12
12
  "react": ">=16.8.0 <19.0.0",
13
- "react-dom": ">=16.8.0 <19.0.0"
13
+ "react-dom": ">=16.8.0 <19.0.0",
14
+ "react-native": "0.75.3",
15
+ "nativewind": "2.0.11"
14
16
  },
15
17
  "dependencies": {},
16
18
  "private": false,
@@ -1,34 +1,18 @@
1
1
  import React, { DetailedHTMLProps, InputHTMLAttributes } from "react";
2
- import { TouchableOpacity, View, StyleSheet } from "react-native";
2
+ import { TouchableOpacity, View } from "react-native";
3
3
 
4
4
  type HTMLElementProps = Omit<
5
5
  DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
6
6
  "ref"
7
7
  >;
8
- export const CheckboxInput = React.forwardRef(function CheckboxInput({ checked, onChange, ...props }, ref){
8
+
9
+ export const CheckboxInput = React.forwardRef(function CheckboxInput({ checked, onChange, ...props }, ref) {
10
+
9
11
  return (
10
- <TouchableOpacity ref={ref} onPress={()=>onChange({currentTarget:{checked:!checked}})} {...props}>
11
- <View style={styles.checkbox}>
12
- {checked && <View style={styles.checkmark} />}
13
- </View>
12
+ <TouchableOpacity ref={ref} onPress={() => onChange({ currentTarget: { checked: !checked, value: props.value } })} {...props}>
13
+ {checked && <View className="ds-checkboxes__input--checked" />}
14
14
  </TouchableOpacity>
15
15
  );
16
16
  });
17
17
 
18
- const styles = StyleSheet.create({
19
- checkbox: {
20
- width: 20,
21
- height: 20,
22
- borderWidth: 2,
23
- borderColor: '#000',
24
- justifyContent: 'center',
25
- alignItems: 'center',
26
- },
27
- checkmark: {
28
- width: 12,
29
- height: 12,
30
- backgroundColor: '#000',
31
- },
32
- });
33
-
34
18
  export default CheckboxInput;
@@ -1,5 +1,5 @@
1
1
  import React, { DetailedHTMLProps, InputHTMLAttributes } from "react";
2
- import { TouchableOpacity, View, Text, StyleSheet } from "react-native";
2
+ import { TouchableOpacity, View } from "react-native";
3
3
 
4
4
  type HTMLElementProps = Omit<
5
5
  DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
@@ -8,9 +8,10 @@ type HTMLElementProps = Omit<
8
8
 
9
9
  export const RadioInput = React.forwardRef(function RadioInput({
10
10
  value,
11
- checked = false,
11
+ checked,
12
12
  onChange,
13
- }: HTMLElementProps, ref) {
13
+ ...props
14
+ }, ref) {
14
15
  const handlePress = () => {
15
16
  if (onChange) {
16
17
  const syntheticEvent = {
@@ -23,30 +24,10 @@ export const RadioInput = React.forwardRef(function RadioInput({
23
24
  }
24
25
  };
25
26
  return (
26
- <TouchableOpacity ref={ref} onPress={handlePress}>
27
- <View style={styles.outerCircle}>
28
- {checked && <View style={styles.innerCircle} />}
29
- </View>
27
+ <TouchableOpacity ref={ref} onPress={handlePress} {...props}>
28
+ {checked && <View className="ds-radios__input--checked" />}
30
29
  </TouchableOpacity>
31
30
  );
32
31
  });
33
32
 
34
33
  export default RadioInput;
35
-
36
- const styles = StyleSheet.create({
37
- outerCircle: {
38
- height: 24,
39
- width: 24,
40
- borderRadius: 12,
41
- borderWidth: 2,
42
- borderColor: '#000',
43
- alignItems: 'center',
44
- justifyContent: 'center',
45
- },
46
- innerCircle: {
47
- height: 12,
48
- width: 12,
49
- borderRadius: 6,
50
- backgroundColor: '#000',
51
- },
52
- });
@@ -1,18 +1,25 @@
1
1
  import React, { DetailedHTMLProps, InputHTMLAttributes, useEffect } from "react";
2
- import { TextInput } from "react-native";
2
+ import { TextInput, } from "react-native";
3
+ import { wrap } from "../../utils";
3
4
 
4
5
  type HTMLElementProps = Omit<
5
6
  DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
6
7
  "ref"
7
8
  >;
8
9
 
9
- export const StringInput = React.forwardRef(function StringInput({type, onChange, onBlur, onFocus, value,maxLength,
10
+ export const StringInput = wrap(React.forwardRef(function StringInput({
11
+ type,
12
+ onChange,
13
+ onBlur,
14
+ onFocus,
15
+ value,
16
+ maxLength,
10
17
  "aria-activedescendant": ariaActivedescendant,
11
18
  "aria-owns": ariaOwns,
12
19
  "aria-autocomplete": ariaAutocomplete,
13
20
  "aria-expanded": ariaExpanded,
14
-
15
- ...props}: HTMLElementProps, ref) {
21
+ ...props
22
+ }: HTMLElementProps, ref) {
16
23
  switch (type) {
17
24
  case "email":
18
25
  props.keyboardType = "email-address";
@@ -52,5 +59,5 @@ export const StringInput = React.forwardRef(function StringInput({type, onChange
52
59
  value={currentValue}
53
60
  maxLength={Number(maxLength) || undefined}
54
61
  {...props} />;
55
- });
62
+ }));
56
63
 
@@ -0,0 +1,21 @@
1
+ import { FormContext } from '@digigov/form/FormContext';
2
+ import { Pressable } from "react-native";
3
+ import React, { useContext } from 'react';
4
+ export const FormButton = React.forwardRef(function FormButton({onClick, ...props}, ref) {
5
+ const formContext = useContext(FormContext)
6
+ return <CompatButton {...props} onClick={()=>{
7
+ onClick && onClick();
8
+ formContext?.[props.type]();
9
+ }} />;
10
+ });
11
+
12
+ export const CompatButton = React.forwardRef(function CompatButton({onClick, ...props}, ref) {
13
+ return <Pressable onPress={onClick} ref={ref} hitSlop={10} {...props} />;
14
+ });
15
+
16
+ export const Button = React.forwardRef(function Button(props, ref) {
17
+ if (['submit', 'reset'].includes(props.type)) {
18
+ return <FormButton ref={ref} {...props} />
19
+ }
20
+ return <CompatButton ref={ref} {...props} />;
21
+ });
@@ -1,110 +1,82 @@
1
- import React, { useRef, useState } from "react";
2
- import { Text, View, ViewProps } from "react-native";
3
- import { mapping } from "@digigov/react-core/Base/mapping";
4
- import { BaseProps as CoreBaseProps } from "@digigov/react-core/Base/index";
1
+ import React, { useRef, useState } from 'react';
2
+ import { Text, View, ViewProps } from 'react-native';
3
+ import { mapping } from '@digigov/react-core/Base/mapping';
4
+ import { BaseProps as CoreBaseProps } from '@digigov/react-core/Base/index.web';
5
5
  import clsx from 'clsx';
6
- import { basePropGenerator } from "./utils";
6
+ import { basePropGenerator, wrap } from '@digigov/react-core/Base/utils';
7
7
  export type BaseProps<C extends React.ElementType> = CoreBaseProps<C> &
8
8
  ViewProps;
9
- export type BaseComponent = <C extends React.ElementType = "span">(
9
+ export type BaseComponent = <C extends React.ElementType = 'span'>(
10
10
  props: BaseProps<C>
11
11
  ) => React.ReactNode | null;
12
- const WrapperComponent = ({classNames, focused, ...props})=>{
13
- const focusedClassNames = focused ? classNames.map(cls=>`${cls}--focus`).join(' ') :' '
14
- return <View className={clsx(classNames.join(' '), focusedClassNames)} {...props} />
15
- }
16
- const Focusable = ({ wrapperClassNames, Component}) =>{
17
- return React.forwardRef(function Focusable(props, ref){
18
- const [focused, setFocused] = useState(false);
19
- return <WrapperComponent classNames={wrapperClassNames} focused={focused}>
20
- <Component
21
- ref={ref}
22
- onFocus={() => {
23
- if (wrapperClassNames.length) {
24
- setFocused(true)
25
- }
26
- }}
27
- onBlur={() => {
28
- if (wrapperClassNames.length) {
29
- setFocused(false)
30
- }
31
- }}
32
- {...props}
33
- />
34
- </WrapperComponent>
35
- })
36
- }
12
+
13
+
37
14
  const BooleanMapper = {
38
15
  true: true,
39
16
  false: false,
40
17
  undefined: false,
41
18
  null: false,
42
- "": false,
19
+ '': false,
43
20
  };
44
- export const Base: BaseComponent = React.forwardRef(function Base({
45
- as,
46
- children,
47
- margin,
48
- marginTop,
49
- marginBottom,
50
- marginLeft,
51
- marginRight,
52
- m,
53
- mt,
54
- mb,
55
- ml,
56
- mr,
57
- mx,
58
- my,
59
- padding,
60
- paddingTop,
61
- paddingBottom,
62
- paddingLeft,
63
- paddingRight,
64
- p,
65
- pt,
66
- pb,
67
- pr,
68
- pl,
69
- px,
70
- py,
71
- printHidden,
72
- printVisible,
73
- hidden,
74
- xsUpHidden,
75
- smUpHidden,
76
- mdUpHidden,
77
- lgUpHidden,
78
- xlUpHidden,
79
- xsHidden,
80
- smHidden,
81
- mdHidden,
82
- lgHidden,
83
- xlHidden,
84
- className,
85
- 'aria-expanded': ariaExpanded,
86
- ...props
87
- }, ref) {
88
- const wrapperClassNames: string[] = []
89
-
90
- const classNames = (className?.split(" ") || [])
91
- .filter((cls) => {
92
- if (cls.endsWith('__wrapper')){
93
- wrapperClassNames.push(cls)
94
- return false
95
- }
96
- return true
97
- })
98
-
99
- if (typeof children === "string") {
21
+ export const Base: BaseComponent = React.forwardRef(function Base(
22
+ {
23
+ as,
24
+ children,
25
+ margin,
26
+ marginTop,
27
+ marginBottom,
28
+ marginLeft,
29
+ marginRight,
30
+ m,
31
+ mt,
32
+ mb,
33
+ ml,
34
+ mr,
35
+ mx,
36
+ my,
37
+ padding,
38
+ paddingTop,
39
+ paddingBottom,
40
+ paddingLeft,
41
+ paddingRight,
42
+ p,
43
+ pt,
44
+ pb,
45
+ pr,
46
+ pl,
47
+ px,
48
+ py,
49
+ printHidden,
50
+ printVisible,
51
+ hidden,
52
+ xsUpHidden,
53
+ smUpHidden,
54
+ mdUpHidden,
55
+ lgUpHidden,
56
+ xlUpHidden,
57
+ xsHidden,
58
+ smHidden,
59
+ mdHidden,
60
+ lgHidden,
61
+ xlHidden,
62
+ className,
63
+ 'aria-expanded': ariaExpanded,
64
+ ...props
65
+ },
66
+ ref
67
+ ) {
68
+ const classNames = className?.split(' ') || []
69
+ if (typeof children === 'string') {
100
70
  children = [children];
101
71
  }
102
72
  if (Array.isArray(children)) {
103
- const textClassNames = classNames?.map((className) => `${className}__text`).join(" ")
73
+ const textClassNames = classNames
74
+ ?.map((className) => `${className}__text`)
75
+ .join(' ');
104
76
  children = children.map((child, index) => {
105
- if(Array.isArray(child)) {
77
+ if (Array.isArray(child)) {
106
78
  return child.map((child, index) => {
107
- if (typeof child === "string") {
79
+ if (typeof child === 'string') {
108
80
  return (
109
81
  <Text key={index} className={textClassNames}>
110
82
  {child}
@@ -113,12 +85,14 @@ export const Base: BaseComponent = React.forwardRef(function Base({
113
85
  }
114
86
  return child;
115
87
  });
116
- }else if (typeof child === "string") {
88
+ } else if (typeof child === 'string') {
117
89
  return (
118
- <Text key={index} className={textClassNames}
119
- {...props.onClick && {
120
- onPress: props.onClick
121
- }}
90
+ <Text
91
+ key={index}
92
+ className={textClassNames}
93
+ {...(props.onClick && {
94
+ onPress: props.onClick,
95
+ })}
122
96
  >
123
97
  {child}
124
98
  </Text>
@@ -128,69 +102,72 @@ export const Base: BaseComponent = React.forwardRef(function Base({
128
102
  });
129
103
  }
130
104
  let Component = mapping[as as keyof JSX.IntrinsicElements] || View;
131
-
132
- if(wrapperClassNames.length > 0){
133
- Component = Focusable({wrapperClassNames, Component})
105
+ if(classNames.find((className) => className.match(/__wrapper|__before|__after$/))) {
106
+ Component = wrap(Component)
134
107
  }
135
- Object.keys(props).forEach((k)=>{
136
- if(k.startsWith('aria')){
137
- if(BooleanMapper[props[k]] !== undefined){
138
- props[k] = BooleanMapper[props[k]]
108
+
109
+ Object.keys(props).forEach((k) => {
110
+ if (k.startsWith('aria')) {
111
+ if (BooleanMapper[props[k]] !== undefined) {
112
+ props[k] = BooleanMapper[props[k]];
139
113
  }
140
114
  }
141
- })
115
+ });
142
116
  return (
143
- <Component
144
- {...props}
145
- ref={ref}
146
- aria-expanded={ariaExpanded === 'false'? false : ariaExpanded === true? true: undefined}
147
- className={
148
- basePropGenerator({
149
- margin,
150
- marginTop,
151
- marginBottom,
152
- marginLeft,
153
- marginRight,
154
- m,
155
- mt,
156
- mb,
157
- ml,
158
- mr,
159
- mx,
160
- my,
161
- padding,
162
- paddingTop,
163
- paddingBottom,
164
- paddingLeft,
165
- paddingRight,
166
- p,
167
- pt,
168
- pb,
169
- pr,
170
- pl,
171
- px,
172
- py,
173
- printHidden,
174
- printVisible,
175
- hidden,
176
- xsUpHidden,
177
- smUpHidden,
178
- mdUpHidden,
179
- lgUpHidden,
180
- xlUpHidden,
181
- xsHidden,
182
- smHidden,
183
- mdHidden,
184
- lgHidden,
185
- xlHidden,
186
- className: (classNames|| []).join(' ')
187
- })
188
- }
189
- >
190
- {children}
191
- </Component>
192
-
117
+ <Component
118
+ {...props}
119
+ ref={ref}
120
+ aria-expanded={
121
+ ariaExpanded === 'false'
122
+ ? false
123
+ : ariaExpanded === true
124
+ ? true
125
+ : undefined
126
+ }
127
+ className={basePropGenerator({
128
+ margin,
129
+ marginTop,
130
+ marginBottom,
131
+ marginLeft,
132
+ marginRight,
133
+ m,
134
+ mt,
135
+ mb,
136
+ ml,
137
+ mr,
138
+ mx,
139
+ my,
140
+ padding,
141
+ paddingTop,
142
+ paddingBottom,
143
+ paddingLeft,
144
+ paddingRight,
145
+ p,
146
+ pt,
147
+ pb,
148
+ pr,
149
+ pl,
150
+ px,
151
+ py,
152
+ printHidden,
153
+ printVisible,
154
+ hidden,
155
+ xsUpHidden,
156
+ smUpHidden,
157
+ mdUpHidden,
158
+ lgUpHidden,
159
+ xlUpHidden,
160
+ xsHidden,
161
+ smHidden,
162
+ mdHidden,
163
+ lgHidden,
164
+ xlHidden,
165
+ className,
166
+ })}
167
+ >
168
+ {children}
169
+ </Component>
193
170
  );
194
171
  });
195
172
 
196
- export default Base;
173
+ export default Base;