@ecohouse/ui 0.1.12 → 0.1.13
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/README.md +14 -14
- package/dist/index.cjs +31 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +32 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Input/Input.stories.tsx +6 -3
- package/src/components/Input/Input.tsx +17 -14
- package/src/components/Input/index.ts +1 -1
- package/src/components/Select/Select.stories.tsx +9 -2
- package/src/components/Select/Select.tsx +11 -11
- package/src/components/Select/index.ts +7 -1
- package/src/components/index.ts +8 -2
- package/src/index.ts +2 -0
- package/src/utils/renderStatefulIcon.tsx +25 -0
package/README.md
CHANGED
|
@@ -140,8 +140,8 @@ export function Example() {
|
|
|
140
140
|
placeholder="••••••••"
|
|
141
141
|
hint="Use at least 8 characters"
|
|
142
142
|
secureTextEntry
|
|
143
|
-
leftIcon={
|
|
144
|
-
rightIcon={
|
|
143
|
+
leftIcon={UserIcon}
|
|
144
|
+
rightIcon={ShowIcon}
|
|
145
145
|
onRightIconPress={() => {}}
|
|
146
146
|
onChangeText={() => {}}
|
|
147
147
|
/>
|
|
@@ -201,18 +201,18 @@ Pill label chip — `default` / `transparent`. Optional leading `HomeIcon` (colo
|
|
|
201
201
|
|
|
202
202
|
Extends React Native `TextInput` props. Default size `lg` (44px pill, radius 60).
|
|
203
203
|
|
|
204
|
-
| Prop | Type | Default
|
|
205
|
-
| ------------------------ | ------------------------------------------------------------ |
|
|
206
|
-
| `label` / `showLabel` | `string` / `boolean` |
|
|
207
|
-
| `hint` / `showHint` | `string` / `boolean` |
|
|
208
|
-
| `placeholder` | `string` |
|
|
209
|
-
| `size` | `"lg" \| "sm"` | `"lg"`
|
|
210
|
-
| `state` | `"default" \| "filled" \| "active" \| "error" \| "disabled"` | derived
|
|
211
|
-
| `disabled` / `error` | `boolean` | `false`
|
|
212
|
-
| `showLeftIcon` | `boolean` | `false`
|
|
213
|
-
| `showRightIcon` | `boolean` | `false`
|
|
214
|
-
| `leftIcon` / `rightIcon` | `
|
|
215
|
-
| `onRightIconPress` | `() => void` | —
|
|
204
|
+
| Prop | Type | Default | Description |
|
|
205
|
+
| ------------------------ | ------------------------------------------------------------ | ---------- | --------------------------------------------------------------- |
|
|
206
|
+
| `label` / `showLabel` | `string` / `boolean` | — / `true` | Top label; omitted when no label is provided |
|
|
207
|
+
| `hint` / `showHint` | `string` / `boolean` | — / `true` | Bottom helper; omitted when no hint is provided |
|
|
208
|
+
| `placeholder` | `string` | — | Field placeholder |
|
|
209
|
+
| `size` | `"lg" \| "sm"` | `"lg"` | Field height |
|
|
210
|
+
| `state` | `"default" \| "filled" \| "active" \| "error" \| "disabled"` | derived | Override auto state |
|
|
211
|
+
| `disabled` / `error` | `boolean` | `false` | Disabled / error chrome |
|
|
212
|
+
| `showLeftIcon` | `boolean` | `false` | Defaults to `UserIcon` |
|
|
213
|
+
| `showRightIcon` | `boolean` | `false` | Defaults to `ShowIcon` |
|
|
214
|
+
| `leftIcon` / `rightIcon` | `InputIcon` | — | Custom icon component or element; receives state color and size |
|
|
215
|
+
| `onRightIconPress` | `() => void` | — | Makes right icon pressable |
|
|
216
216
|
|
|
217
217
|
| State | Behavior |
|
|
218
218
|
| ---------- | -------------------------------------------------------------------- |
|
package/dist/index.cjs
CHANGED
|
@@ -2758,6 +2758,19 @@ var styles10 = reactNative.StyleSheet.create({
|
|
|
2758
2758
|
backgroundColor: colors.primary
|
|
2759
2759
|
}
|
|
2760
2760
|
});
|
|
2761
|
+
function renderStatefulIcon(icon, FallbackIcon, props) {
|
|
2762
|
+
if (icon == null) {
|
|
2763
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FallbackIcon, { ...props });
|
|
2764
|
+
}
|
|
2765
|
+
if (typeof icon === "function") {
|
|
2766
|
+
const Icon2 = icon;
|
|
2767
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Icon2, { ...props });
|
|
2768
|
+
}
|
|
2769
|
+
if (react.isValidElement(icon)) {
|
|
2770
|
+
return react.cloneElement(icon, props);
|
|
2771
|
+
}
|
|
2772
|
+
return icon;
|
|
2773
|
+
}
|
|
2761
2774
|
var DEFAULT_WIDTH2 = 308;
|
|
2762
2775
|
var sizeConfig2 = {
|
|
2763
2776
|
lg: {
|
|
@@ -2837,11 +2850,11 @@ function chromeFor(state) {
|
|
|
2837
2850
|
}
|
|
2838
2851
|
}
|
|
2839
2852
|
var Input = react.forwardRef(function Input2({
|
|
2840
|
-
label
|
|
2853
|
+
label,
|
|
2841
2854
|
showLabel = true,
|
|
2842
|
-
hint
|
|
2855
|
+
hint,
|
|
2843
2856
|
showHint = true,
|
|
2844
|
-
placeholder
|
|
2857
|
+
placeholder,
|
|
2845
2858
|
size = "lg",
|
|
2846
2859
|
disabled = false,
|
|
2847
2860
|
error = false,
|
|
@@ -2878,8 +2891,14 @@ var Input = react.forwardRef(function Input2({
|
|
|
2878
2891
|
const resolvedAccessibilityLabel = accessibilityLabel ?? (showLabel ? void 0 : label);
|
|
2879
2892
|
const hasLeftIcon = showLeftIcon || leftIcon != null;
|
|
2880
2893
|
const hasRightIcon = showRightIcon || rightIcon != null;
|
|
2881
|
-
const leftIconNode = leftIcon
|
|
2882
|
-
|
|
2894
|
+
const leftIconNode = renderStatefulIcon(leftIcon, UserIcon, {
|
|
2895
|
+
size: metrics.iconSize,
|
|
2896
|
+
color: chrome.leftIconColor
|
|
2897
|
+
});
|
|
2898
|
+
const rightIconNode = renderStatefulIcon(rightIcon, ShowIcon, {
|
|
2899
|
+
size: metrics.iconSize,
|
|
2900
|
+
color: chrome.rightIconColor
|
|
2901
|
+
});
|
|
2883
2902
|
useApplyWebClassName(rootRef, className);
|
|
2884
2903
|
useApplyWebClassName(inputRef, inputClassName);
|
|
2885
2904
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: rootRef, style: [styles11.root, disabled && styles11.disabled, style], children: [
|
|
@@ -3113,11 +3132,11 @@ function MultiValueChips({ options, disabled, onRemove }) {
|
|
|
3113
3132
|
var Select = react.forwardRef(
|
|
3114
3133
|
function Select2(props, forwardedRef) {
|
|
3115
3134
|
const {
|
|
3116
|
-
label
|
|
3135
|
+
label,
|
|
3117
3136
|
showLabel = true,
|
|
3118
3137
|
hint,
|
|
3119
|
-
showHint =
|
|
3120
|
-
placeholder
|
|
3138
|
+
showHint = true,
|
|
3139
|
+
placeholder,
|
|
3121
3140
|
options,
|
|
3122
3141
|
open: openProp,
|
|
3123
3142
|
defaultOpen = false,
|
|
@@ -3314,13 +3333,10 @@ var Select = react.forwardRef(
|
|
|
3314
3333
|
handleSelect,
|
|
3315
3334
|
setOpen
|
|
3316
3335
|
]);
|
|
3317
|
-
const leftIconNode = leftIcon
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
color: error ? colors.red : isOpen ? colors.primary : colors.grey100
|
|
3322
|
-
}
|
|
3323
|
-
);
|
|
3336
|
+
const leftIconNode = renderStatefulIcon(leftIcon, UserIcon, {
|
|
3337
|
+
size: ICON_SIZE7,
|
|
3338
|
+
color: error ? colors.red : isOpen ? colors.primary : colors.grey100
|
|
3339
|
+
});
|
|
3324
3340
|
const hasLeftIcon = showLeftIcon || leftIcon != null;
|
|
3325
3341
|
const triggerBorderColor = error ? colors.redMuted : isOpen ? colors.primaryMuted : colors.grey700;
|
|
3326
3342
|
const triggerTextColor = hasValue ? error ? colors.red : colors.white : error ? colors.red : colors.grey100;
|