@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
@@ -4,31 +4,20 @@ import BaseInput from "./compat/Input";
4
4
  import CompatDetails from "./compat/details";
5
5
  import Svg, { Path, Circle, Rect, G, Polygon } from "react-native-svg";
6
6
  import { Link } from "expo-router";
7
- import { FormContext } from '@digigov/form/FormContext';
8
7
  import {Li} from "./compat/li";
9
8
  import {Ol} from "./compat/ol";
9
+ import { Button } from "./compat/button";
10
10
  export type MapProps<T extends keyof JSX.IntrinsicElements> =
11
11
  React.ComponentPropsWithoutRef<T>;
12
12
  export type MappingType = {
13
13
  [K in keyof JSX.IntrinsicElements]?: (props: MapProps<K>) => JSX.Element;
14
14
  };
15
15
 
16
- const Button = (props) => {
17
- return <Pressable onPress={props.onClick} hitSlop={10} {...props} />;
18
- };
19
- const SubmitButton = (props) => {
20
- const formContext = useContext(FormContext)
21
- return <Button {...props} onClick={formContext?.submit} />;
22
- };
16
+
23
17
  export const mapping: MappingType = {
24
18
  a: Link,
25
19
  img: Image,
26
- button: React.forwardRef(function CompatButton(props,ref) {
27
- if(props.type === 'submit') {
28
- return <SubmitButton ref={ref} {...props} />
29
- }
30
- return <Button ref={ref} {...props} />
31
- }),
20
+ button: Button,
32
21
  input: BaseInput,
33
22
  textarea: React.forwardRef(function TextAreaInput(props,ref) {
34
23
  return <TextInput ref={ref} multiline={true} scrollEnabled={true} {...props} />
@@ -1,4 +1,6 @@
1
1
  import clsx from 'clsx';
2
+ import React, { useContext, useMemo, useState } from 'react';
3
+ import { View } from 'react-native';
2
4
 
3
5
  export const basePropGenerator = ({
4
6
  margin,
@@ -81,4 +83,64 @@ export const basePropGenerator = ({
81
83
  'ds-hidden-md': !!mdHidden,
82
84
  'ds-hidden-lg': !!lgHidden,
83
85
  'ds-hidden-xl': !!xlHidden,
84
- })
86
+ })
87
+ const WrapperContext = React.createContext((cls)=>{return cls});
88
+ const Wrapper = ({children})=>{
89
+ const [className, setClassName] = useState('');
90
+ return <WrapperContext.Provider value={setClassName}>
91
+ <View className={className} focusable={false}>
92
+ {children}
93
+ </View>
94
+ </WrapperContext.Provider>
95
+ }
96
+
97
+ export const wrap = (Component) => {
98
+ // @ts-ignore
99
+ const WrappedComponent = React.forwardRef(({className, onBlur, onFocus, ...props}, ref)=>{
100
+ const setClassName = useContext(WrapperContext);
101
+ const wrapperClassNames: string[] = [];
102
+ const beforeClassNames: string[] = [];
103
+ const afterClassNames: string[] = [];
104
+ const focusedWrapperClassNames: string[] = []
105
+ const classNames = useMemo(() => (className?.split(' ') || []).filter((cls) => {
106
+ if (
107
+ cls.endsWith('__wrapper')
108
+ ) {
109
+ wrapperClassNames.push(cls);
110
+ focusedWrapperClassNames.push(`${cls}--focus`);
111
+ return false;
112
+ } else if (cls.endsWith('__before')) {
113
+ beforeClassNames.push(cls);
114
+ return false;
115
+ } else if (cls.endsWith('__after')) {
116
+ afterClassNames.push(cls);
117
+ return false;
118
+ }
119
+ return true;
120
+ }), []);
121
+ return <>
122
+ {beforeClassNames.length ? <View focusable={false} className={beforeClassNames.join(' ')} />: ''}
123
+ <Component
124
+ onFocus={(e) => {
125
+ setClassName(focusedWrapperClassNames.join(' '));
126
+ onFocus && onFocus(e);
127
+ }}
128
+ onBlur={(e) => {
129
+ setClassName(wrapperClassNames.join(' '));
130
+ onBlur && onBlur(e);
131
+ }}
132
+ className={classNames.join(' ')}
133
+ {...props}
134
+ />
135
+ {afterClassNames.length ? <View focusable={false} className={afterClassNames.join(' ')} />: ''}
136
+
137
+ </>
138
+ })
139
+ return React.forwardRef(function Wrapped({ ...props }, ref) {
140
+ return (
141
+ <Wrapper>
142
+ <WrappedComponent {...props} ref={ref}/>
143
+ </Wrapper>
144
+ );
145
+ });
146
+ };
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import clsx from 'clsx';
3
3
  import Base, { BaseProps } from '@digigov/react-core/Base';
4
4
  import ChoiceDividerText from '@digigov/react-core/ChoiceDividerText';
5
+ import CheckboxItemInput from '@digigov/react-core/CheckboxItemInput';
5
6
  import LabelContainer from '@digigov/react-core/LabelContainer';
6
7
 
7
8
  export interface CheckboxItemProps extends BaseProps<'input'> {
@@ -39,18 +40,7 @@ export const CheckboxItem = React.forwardRef<
39
40
  })}
40
41
  >
41
42
  {children}
42
- <Base
43
- as="input"
44
- ref={ref}
45
- type="checkbox"
46
- name={name}
47
- value={value}
48
- className={clsx({
49
- 'ds-checkboxes__input': true,
50
- })}
51
- disabled={disabled}
52
- {...props}
53
- />
43
+ <CheckboxItemInput ref={ref} name={name} value={value} disabled={disabled} {...props} />
54
44
  </LabelContainer>
55
45
  </Base>
56
46
  </>
@@ -0,0 +1,10 @@
1
+ import extend from '@digigov/react-core/utils/extend';
2
+ import CoreCheckboxItemInput from '@digigov/react-core/CheckboxItemInput/index.web';
3
+ import clsx from 'clsx';
4
+ export const CheckboxItemInput = extend(CoreCheckboxItemInput, ({ className, ...props }) => ({
5
+ ...props,
6
+ className: clsx(className, {
7
+ 'ds-checkboxes__input__wrapper': true
8
+ })
9
+ }))
10
+ export default CheckboxItemInput;
@@ -0,0 +1,2 @@
1
+ export * from '@digigov/react-core/CheckboxItemInput/index.web';
2
+ export { default as default } from '@digigov/react-core/CheckboxItemInput/index.web';
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ import Base, { BaseProps } from '@digigov/react-core/Base';
4
+
5
+ export interface CheckboxItemInputProps extends BaseProps<'input'> { }
6
+ /**
7
+ * Details for the CheckboxItem.
8
+ * CheckboxItemInput component is the input component for CheckboxItem.
9
+ */
10
+ export const CheckboxItemInput = React.forwardRef<
11
+ HTMLInputElement,
12
+ CheckboxItemInputProps
13
+ >(function CheckboxItemInput(
14
+ { name, value, className, disabled, children, ...props },
15
+ ref
16
+ ) {
17
+ return (
18
+ <Base
19
+ as="input"
20
+ ref={ref}
21
+ type="checkbox"
22
+ name={name}
23
+ value={value}
24
+ className={clsx({
25
+ 'ds-checkboxes__input': true,
26
+ })}
27
+ disabled={disabled}
28
+ {...props}
29
+ />
30
+
31
+ );
32
+ });
33
+
34
+ export default CheckboxItemInput;
@@ -1,74 +1,2 @@
1
- import React from 'react';
2
- import clsx from 'clsx';
3
- import Base, { BaseProps } from '@digigov/react-core/Base';
4
-
5
- export interface CopyToClipboardContainerProps extends BaseProps<'div'> {
6
- /**
7
- * @value 'tooltip' is used when you want to show the message inside a tooltip.
8
- * @value 'banner' is used when you want to show the message inside a banner.
9
- * @default 'tooltip'
10
- */
11
- variant?: 'tooltip' | 'banner';
12
- /**
13
- * tooltipAlign is optional.
14
- * tooltipAlign prop adds tooltip right or left and is used only if variant is tooltip.
15
- * @value 'right'
16
- * @value 'left'
17
- * @default 'right'
18
- */
19
- tooltipAlign?: 'right' | 'left';
20
- /**
21
- * dense is optional.
22
- * affects only the density of the tooltip.
23
- * @value true tooltip will be dense.
24
- * @value false
25
- * @default false
26
- * */
27
- dense?: boolean;
28
- }
29
- /**
30
- * CopyToClipboardContainer is a wrapper component for CopyToClipboardMessage
31
- */
32
- export const CopyToClipboardContainer = React.forwardRef<
33
- HTMLDivElement,
34
- CopyToClipboardContainerProps
35
- >(function CopyToClipboardContainer(
36
- {
37
- variant = 'tooltip',
38
- tooltipAlign = 'right',
39
- className,
40
- dense,
41
- children,
42
- ...props
43
- },
44
- ref
45
- ) {
46
- return (
47
- <Base
48
- as="div"
49
- ref={ref}
50
- {...props}
51
- className={clsx(className, {
52
- 'ds-copy-to-clipboard': true,
53
- })}
54
- {...props}
55
- >
56
- <div
57
- className={clsx(className, {
58
- 'ds-copy-to-clipboard__tooltip': variant === 'tooltip',
59
- 'ds-copy-to-clipboard__tooltip--dense':
60
- variant === 'tooltip' && dense,
61
- 'ds-copy-to-clipboard__tooltip--left':
62
- variant === 'tooltip' && tooltipAlign === 'left',
63
- 'ds-copy-to-clipboard__tooltip--right':
64
- variant === 'tooltip' && tooltipAlign === 'right',
65
- 'ds-copy-to-clipboard__banner': variant === 'banner',
66
- })}
67
- >
68
- {children}
69
- </div>
70
- </Base>
71
- );
72
- });
73
-
74
- export default CopyToClipboardContainer;
1
+ export * from '@digigov/react-core/CopyToClipboardContainer/index.web';
2
+ export { default as default } from '@digigov/react-core/CopyToClipboardContainer/index.web';
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ import Base, { BaseProps } from '@digigov/react-core/Base';
4
+
5
+ export interface CopyToClipboardContainerProps extends BaseProps<'div'> {
6
+ /**
7
+ * @value 'tooltip' is used when you want to show the message inside a tooltip.
8
+ * @value 'banner' is used when you want to show the message inside a banner.
9
+ * @default 'tooltip'
10
+ */
11
+ variant?: 'tooltip' | 'banner';
12
+ /**
13
+ * tooltipAlign is optional.
14
+ * tooltipAlign prop adds tooltip right or left and is used only if variant is tooltip.
15
+ * @value 'right'
16
+ * @value 'left'
17
+ * @default 'right'
18
+ */
19
+ tooltipAlign?: 'right' | 'left';
20
+ /**
21
+ * dense is optional.
22
+ * affects only the density of the tooltip.
23
+ * @value true tooltip will be dense.
24
+ * @value false
25
+ * @default false
26
+ * */
27
+ dense?: boolean;
28
+ }
29
+ /**
30
+ * CopyToClipboardContainer is a wrapper component for CopyToClipboardMessage
31
+ */
32
+ export const CopyToClipboardContainer = React.forwardRef<
33
+ HTMLDivElement,
34
+ CopyToClipboardContainerProps
35
+ >(function CopyToClipboardContainer(
36
+ {
37
+ variant = 'tooltip',
38
+ tooltipAlign = 'right',
39
+ className,
40
+ dense,
41
+ children,
42
+ ...props
43
+ },
44
+ ref
45
+ ) {
46
+ return (
47
+ <Base
48
+ as="div"
49
+ ref={ref}
50
+ {...props}
51
+ className={clsx(className, {
52
+ 'ds-copy-to-clipboard': true,
53
+ })}
54
+ {...props}
55
+ >
56
+ <Base
57
+ as="div"
58
+ className={clsx(className, {
59
+ 'ds-copy-to-clipboard__tooltip': variant === 'tooltip',
60
+ 'ds-copy-to-clipboard__tooltip--dense':
61
+ variant === 'tooltip' && dense,
62
+ 'ds-copy-to-clipboard__tooltip--left':
63
+ variant === 'tooltip' && tooltipAlign === 'left',
64
+ 'ds-copy-to-clipboard__tooltip--right':
65
+ variant === 'tooltip' && tooltipAlign === 'right',
66
+ 'ds-copy-to-clipboard__banner': variant === 'banner',
67
+ })}
68
+ >
69
+ {children}
70
+ </Base>
71
+ </Base>
72
+ );
73
+ });
74
+
75
+ export default CopyToClipboardContainer;
@@ -0,0 +1,24 @@
1
+ import CoreCopyToClipboardMessage, {
2
+ CopyToClipboardMessageProps,
3
+ } from '@digigov/react-core/CopyToClipboardMessage/index.web';
4
+ import { CopyToClipboardContainerProps } from '@digigov/react-core/CopyToClipboardContainer';
5
+ import { extend } from '@digigov/react-core/utils/extend';
6
+ import clsx from 'clsx';
7
+
8
+ export const CopyToClipboardMessage = extend<
9
+ CopyToClipboardMessageProps,
10
+ CopyToClipboardContainerProps
11
+ >(
12
+ CoreCopyToClipboardMessage,
13
+ ({ dense, className, ...props }) => {
14
+ return {
15
+ className: clsx(className, {
16
+ 'ds-copy-to-clipboard__before': true,
17
+ 'ds-copy-to-clipboard__message--dense': dense,
18
+ }),
19
+ ...props,
20
+ };
21
+ }
22
+ );
23
+
24
+ export default CopyToClipboardMessage;
@@ -1,41 +1,2 @@
1
- import React from 'react';
2
- import clsx from 'clsx';
3
- import Base, { BaseProps } from '@digigov/react-core/Base';
4
-
5
- export interface CopyToClipboardMessageProps extends BaseProps<'div'> {
6
- /**
7
- * enabled is a boolean prop passed from the CopyToClipboard component.
8
- * When it's true it shows the CopyToClipboardMessage component and it activates the animation that hides the component after 3s.
9
- * When it's false it resets the animations of the CopyToClipboardMessage.
10
- * @value true
11
- * @value false
12
- */
13
- enabled?: boolean;
14
- }
15
- /**
16
- * CopyToClipboardMessage is used to show a message that a text is being copied.
17
- * This component is used inside the CopyToClipboard component that lies inside the digigov/ui library
18
- */
19
- export const CopyToClipboardMessage = React.forwardRef<
20
- HTMLDivElement,
21
- CopyToClipboardMessageProps
22
- >(function CopyToClipboardMessage(
23
- { enabled, className, children, ...props },
24
- ref
25
- ) {
26
- return (
27
- <Base
28
- as="div"
29
- ref={ref}
30
- className={clsx(className, {
31
- 'ds-copy-to-clipboard__message': true,
32
- 'ds-copy-to-clipboard--hidden': !enabled,
33
- })}
34
- {...props}
35
- >
36
- {children}
37
- </Base>
38
- );
39
- });
40
-
41
- export default CopyToClipboardMessage;
1
+ export * from '@digigov/react-core/CopyToClipboardMessage/index.web';
2
+ export { default as default } from '@digigov/react-core/CopyToClipboardMessage/index.web';
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ import Base, { BaseProps } from '@digigov/react-core/Base';
4
+
5
+ export interface CopyToClipboardMessageProps extends BaseProps<'div'> {
6
+ /**
7
+ * enabled is a boolean prop passed from the CopyToClipboard component.
8
+ * When it's true it shows the CopyToClipboardMessage component and it activates the animation that hides the component after 3s.
9
+ * When it's false it resets the animations of the CopyToClipboardMessage.
10
+ * @value true
11
+ * @value false
12
+ */
13
+ enabled?: boolean;
14
+ }
15
+ /**
16
+ * CopyToClipboardMessage is used to show a message that a text is being copied.
17
+ * This component is used inside the CopyToClipboard component that lies inside the digigov/ui library
18
+ */
19
+ export const CopyToClipboardMessage = React.forwardRef<
20
+ HTMLDivElement,
21
+ CopyToClipboardMessageProps
22
+ >(function CopyToClipboardMessage(
23
+ { enabled, className, children, ...props },
24
+ ref
25
+ ) {
26
+ return (
27
+ <Base
28
+ as="div"
29
+ ref={ref}
30
+ className={clsx(className, {
31
+ 'ds-copy-to-clipboard__message': true,
32
+ 'ds-copy-to-clipboard--hidden': !enabled,
33
+ })}
34
+ {...props}
35
+ >
36
+ {children}
37
+ </Base>
38
+ );
39
+ });
40
+
41
+ export default CopyToClipboardMessage;
@@ -0,0 +1,10 @@
1
+ import extend from '@digigov/react-core/utils/extend';
2
+ import CoreTextInput from '@digigov/react-core/TextInput/index.web';
3
+ import clsx from 'clsx';
4
+ export const TextInput = extend(CoreTextInput, ({ className, ...props }) => ({
5
+ ...props,
6
+ className: clsx(className, {
7
+ 'ds-input__wrapper': true
8
+ })
9
+ }))
10
+ export default TextInput;
@@ -1,87 +1,2 @@
1
- import React from 'react';
2
- import clsx from 'clsx';
3
- import Base, { BaseProps } from '@digigov/react-core/Base';
4
-
5
- export interface TextInputProps extends BaseProps<'input'> {
6
- /**
7
- * maxWidth is optional.
8
- * @value '2-char';
9
- * @value '3-char';
10
- * @value '4-char';
11
- * @value '5-char';
12
- * @value '10-char';
13
- * @value '20-char';
14
- */
15
- maxWidth?: '2-char' | '3-char' | '4-char' | '5-char' | '10-char' | '20-char';
16
-
17
- /**
18
- * width is optional.
19
- * Use width prop to define a custom width in your component.
20
- * @value '25%';
21
- * @value '33.3%';
22
- * @value '50%';
23
- * @value '66.6%';
24
- * @value '75%';
25
- * @value '100%';
26
- * @value 'full';
27
- */
28
- width?: '25%' | '33.3%' | '50%' | '66.6%' | '75%' | '100%' | 'full';
29
-
30
- /**
31
- * error is optional. The default value is false.
32
- * Use this prop when there is an error at the input.
33
- * @value true
34
- * @value false
35
- */
36
- error?: boolean;
37
- /**
38
- * dense is optional.
39
- * @value true TextInput will be dense.
40
- * @value false
41
- * @default false
42
- */
43
- dense?: boolean;
44
- }
45
- /**
46
- * TextInput component when you need to let users enter text that’s no
47
- * longer than a single line, such as their name or phone number.
48
- */
49
- export const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
50
- function TextInput(
51
- {
52
- type = 'text',
53
- maxWidth,
54
- width,
55
- error,
56
- dense,
57
- className,
58
- children,
59
- ...props
60
- },
61
- ref
62
- ) {
63
- return (
64
- <Base
65
- as="input"
66
- type={type}
67
- ref={ref}
68
- className={clsx(className, {
69
- 'ds-input': true,
70
- 'ds-input--error': error,
71
- 'ds-input--dense': dense,
72
- [`ds-input--width-${maxWidth}`]: maxWidth !== undefined,
73
- 'ds-!-width-one-quarter': width === '25%',
74
- 'ds-!-width-one-third': width === '33.3%',
75
- 'ds-!-width-one-half': width === '50%',
76
- 'ds-!-width-two-thirds': width === '66.6%',
77
- 'ds-!-width-three-quarters': width === '75%',
78
- })}
79
- {...props}
80
- >
81
- {children}
82
- </Base>
83
- );
84
- }
85
- );
86
-
87
- export default TextInput;
1
+ export * from '@digigov/react-core/TextInput/index.web';
2
+ export { default as default } from '@digigov/react-core/TextInput/index.web';
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ import Base, { BaseProps } from '@digigov/react-core/Base';
4
+
5
+ export interface TextInputProps extends BaseProps<'input'> {
6
+ /**
7
+ * maxWidth is optional.
8
+ * @value '2-char';
9
+ * @value '3-char';
10
+ * @value '4-char';
11
+ * @value '5-char';
12
+ * @value '10-char';
13
+ * @value '20-char';
14
+ */
15
+ maxWidth?: '2-char' | '3-char' | '4-char' | '5-char' | '10-char' | '20-char';
16
+
17
+ /**
18
+ * width is optional.
19
+ * Use width prop to define a custom width in your component.
20
+ * @value '25%';
21
+ * @value '33.3%';
22
+ * @value '50%';
23
+ * @value '66.6%';
24
+ * @value '75%';
25
+ * @value '100%';
26
+ * @value 'full';
27
+ */
28
+ width?: '25%' | '33.3%' | '50%' | '66.6%' | '75%' | '100%' | 'full';
29
+
30
+ /**
31
+ * error is optional. The default value is false.
32
+ * Use this prop when there is an error at the input.
33
+ * @value true
34
+ * @value false
35
+ */
36
+ error?: boolean;
37
+ /**
38
+ * dense is optional.
39
+ * @value true TextInput will be dense.
40
+ * @value false
41
+ * @default false
42
+ */
43
+ dense?: boolean;
44
+ }
45
+ /**
46
+ * TextInput component when you need to let users enter text that’s no
47
+ * longer than a single line, such as their name or phone number.
48
+ */
49
+ export const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
50
+ function TextInput(
51
+ {
52
+ type = 'text',
53
+ maxWidth,
54
+ width,
55
+ error,
56
+ dense,
57
+ className,
58
+ children,
59
+ ...props
60
+ },
61
+ ref
62
+ ) {
63
+ return (
64
+ <Base
65
+ as="input"
66
+ type={type}
67
+ ref={ref}
68
+ className={clsx(className, {
69
+ 'ds-input': true,
70
+ 'ds-input--error': error,
71
+ 'ds-input--dense': dense,
72
+ [`ds-input--width-${maxWidth}`]: maxWidth !== undefined,
73
+ 'ds-!-width-one-quarter': width === '25%',
74
+ 'ds-!-width-one-third': width === '33.3%',
75
+ 'ds-!-width-one-half': width === '50%',
76
+ 'ds-!-width-two-thirds': width === '66.6%',
77
+ 'ds-!-width-three-quarters': width === '75%',
78
+ })}
79
+ {...props}
80
+ >
81
+ {children}
82
+ </Base>
83
+ );
84
+ }
85
+ );
86
+
87
+ export default TextInput;