@onehat/ui 0.4.53 → 0.4.55

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/ui",
3
- "version": "0.4.53",
3
+ "version": "0.4.55",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -68,7 +68,7 @@
68
68
  "native-base": "^3.4.28",
69
69
  "react-hook-form": "^7.55.0",
70
70
  "react-redux": "^9.2.0",
71
- "tailwindcss": "^4.1.0",
71
+ "tailwindcss": "^3.4.17",
72
72
  "yup": "^1.6.1"
73
73
  },
74
74
  "peerDependencies": {
@@ -1,4 +1,4 @@
1
- import { forwardRef, useState, useEffect, useRef, } from 'react';
1
+ import { cloneElement, forwardRef, isValidElement, useState, useEffect, useRef, } from 'react';
2
2
  import {
3
3
  Input, InputField, InputIcon, InputSlot,
4
4
  } from '@project-components/Gluestack';
@@ -13,7 +13,7 @@ import withValue from '../../Hoc/withValue.js';
13
13
  import _ from 'lodash';
14
14
 
15
15
  const InputElement = forwardRef((props, ref) => {
16
- let { // so localValue can be changed, if needed
16
+ let {
17
17
  value,
18
18
  setValue,
19
19
  maxLength,
@@ -22,11 +22,13 @@ const InputElement = forwardRef((props, ref) => {
22
22
  disableAutoFlex = false,
23
23
  onKeyPress,
24
24
  onChangeText,
25
- leftElement,
26
- leftIcon,
25
+ leftElement = null,
26
+ leftIcon = null,
27
+ _leftIcon,
27
28
  leftIconHandler,
28
- rightElement,
29
- rightIcon,
29
+ rightElement = null,
30
+ rightIcon = null,
31
+ _rightIcon,
30
32
  rightIconHandler,
31
33
  placeholder,
32
34
  textAlignIsCenter = false,
@@ -127,24 +129,63 @@ const InputElement = forwardRef((props, ref) => {
127
129
  if (className) {
128
130
  inputClassName += className;
129
131
  }
132
+
133
+
134
+ if (leftElement) {
135
+ leftElement = <InputSlot className="leftElementInputSlot">{leftElement}</InputSlot>;
136
+ }
137
+ if (leftIcon) {
138
+ if (!_leftIcon) {
139
+ _leftIcon = {};
140
+ }
141
+ if (!_leftIcon.className) {
142
+ _leftIcon.className = '';
143
+ }
144
+ _leftIcon.className = 'leftInputIcon mr-2 ' + _leftIcon.className; // prepend the margin, so it can potentially be overridden
145
+ if (isValidElement(leftIcon)) {
146
+ if (_leftIcon) {
147
+ leftIcon = cloneElement(leftIcon, {..._leftIcon});
148
+ }
149
+ } else {
150
+ leftIcon = <InputIcon as={leftIcon} {..._leftIcon} />;
151
+ }
152
+ if (leftIconHandler) {
153
+ leftIcon = <InputSlot onPress={leftIconHandler} className="LeftInputSlot">
154
+ {leftIcon}
155
+ </InputSlot>;
156
+ }
157
+ }
158
+ if (rightElement) {
159
+ rightElement = <InputSlot className="rightElementInputSlot">{rightElement}</InputSlot>;
160
+ }
161
+ if (rightIcon) {
162
+ if (!_rightIcon) {
163
+ _rightIcon = {};
164
+ }
165
+ if (!_rightIcon.className) {
166
+ _rightIcon.className = '';
167
+ }
168
+ _rightIcon.className = 'rightInputIcon ml-2 ' + _rightIcon.className; // prepend the margin, so it can potentially be overridden
169
+ if (isValidElement(rightIcon)) {
170
+ if (_rightIcon) {
171
+ rightIcon = cloneElement(rightIcon, {..._rightIcon});
172
+ }
173
+ } else {
174
+ rightIcon = <InputIcon as={rightIcon} {..._rightIcon} />;
175
+ }
176
+ if (rightIconHandler) {
177
+ rightIcon = <InputSlot onPress={rightIconHandler} className="RightInputSlot">
178
+ {rightIcon}
179
+ </InputSlot>;
180
+ }
181
+ }
130
182
 
131
183
  return <Input
132
184
  className={inputClassName}
133
185
  style={style}
134
186
  >
135
- {leftElement &&
136
- <InputSlot className="leftElementInputSlot">{leftElement}</InputSlot>}
137
-
138
- {leftIcon && leftIconHandler &&
139
- <InputSlot onPress={leftIconHandler} className="InputSlot">
140
- <InputIcon className="leftInputIconWithHandler ml-2">
141
- {leftIcon}
142
- </InputIcon>
143
- </InputSlot>}
144
- {leftIcon && !leftIconHandler &&
145
- <InputIcon className="leftInputIcon ml-2">
146
- {leftIcon}
147
- </InputIcon>}
187
+ {leftElement}
188
+ {leftIcon}
148
189
 
149
190
  <InputField
150
191
  ref={ref}
@@ -158,19 +199,8 @@ const InputElement = forwardRef((props, ref) => {
158
199
  {...propsToPass}
159
200
  />
160
201
 
161
- {rightElement &&
162
- <InputSlot className="rightElementInputSlot">{rightElement}</InputSlot>}
163
-
164
- {rightIcon && rightIconHandler &&
165
- <InputSlot onPress={rightIconHandler} className="InputSlot">
166
- <InputIcon className="rightInputIconWithHandler mr-2">
167
- {rightIcon}
168
- </InputIcon>
169
- </InputSlot>}
170
- {rightIcon && !rightIconHandler &&
171
- <InputIcon className="rightInputIcon mr-2">
172
- {rightIcon}
173
- </InputIcon>}
202
+ {rightElement}
203
+ {rightIcon}
174
204
  </Input>;
175
205
  });
176
206