@dloizides/ui-forms 1.0.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.
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/index.d.mts +51 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +241 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +233 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +108 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
Initial release. Extracted the proven duplicated form components from erevna-web ↔ katalogos-web
|
|
6
|
+
(Capability Wave C1, batch 2).
|
|
7
|
+
|
|
8
|
+
- `FormField`, `ChipSelector`, `FormSwitch` — share the `@dloizides/ui-feedback` UI context (`useUi`).
|
|
9
|
+
- `FormActions` deferred (depends on a not-yet-shared `core/Button`).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 dloizides
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @dloizides/ui-forms
|
|
2
|
+
|
|
3
|
+
Themable, brand-agnostic React Native (RN-web) **form** components for the dloizides.com
|
|
4
|
+
portfolio: `FormField`, `ChipSelector`, `FormSwitch`. They read theme colours from the shared
|
|
5
|
+
`@dloizides/ui-feedback` UI context (`useUi`) — mount one `UiProvider` / `FeedbackUiProvider`
|
|
6
|
+
at your app root and these components pick up your theme automatically.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @dloizides/ui-forms @dloizides/ui-feedback
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Peer dependencies: `@dloizides/ui-feedback >= 1.1.0`, `react >= 18`, `react-native >= 0.74`
|
|
15
|
+
(use `react-native-web` on web).
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { FormField, ChipSelector, FormSwitch } from '@dloizides/ui-forms';
|
|
21
|
+
|
|
22
|
+
<FormField label="Email" required error={errors.email} value={email} onChangeText={setEmail} />
|
|
23
|
+
<ChipSelector label="Plan" options={plans} value={plan} onChange={setPlan} />
|
|
24
|
+
<FormSwitch label="Email notifications" value={notify} onValueChange={setNotify} />
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The injected theme needs `colors.{surface,text,textSecondary,border}`, `palette.primary['500']`
|
|
28
|
+
and `semantic.error['500']` — supplied via `@dloizides/ui-feedback`'s provider. Without a provider
|
|
29
|
+
the components fall back to a neutral default theme.
|
|
30
|
+
|
|
31
|
+
## testIDs
|
|
32
|
+
|
|
33
|
+
`form-field-input`, `chip-selector-chip-<value>`, `form-switch` (overridable on FormSwitch).
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextInputProps, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Reusable form field — labelled text input with optional required mark + error.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface FormFieldProps extends Omit<TextInputProps, 'style'> {
|
|
9
|
+
label: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
containerStyle?: ViewStyle;
|
|
13
|
+
}
|
|
14
|
+
declare const FormField: ({ label, required, error, containerStyle, ...textInputProps }: FormFieldProps) => React.ReactElement;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Chip/pill selector for selecting one or multiple options.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface ChipOption<T> {
|
|
21
|
+
value: T;
|
|
22
|
+
label: string;
|
|
23
|
+
}
|
|
24
|
+
interface ChipSelectorProps<T> {
|
|
25
|
+
label?: string;
|
|
26
|
+
options: Array<ChipOption<T>>;
|
|
27
|
+
value: T | T[];
|
|
28
|
+
onChange: (value: T) => void;
|
|
29
|
+
multiple?: boolean;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
containerStyle?: ViewStyle;
|
|
32
|
+
}
|
|
33
|
+
declare const ChipSelector: <T extends string | number>({ label, options, value, onChange, multiple, disabled, containerStyle, }: ChipSelectorProps<T>) => React.ReactElement;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Reusable form switch/toggle with an optional description.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
interface FormSwitchProps {
|
|
40
|
+
label: string;
|
|
41
|
+
value: boolean;
|
|
42
|
+
onValueChange: (value: boolean) => void;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
description?: string;
|
|
45
|
+
containerStyle?: ViewStyle;
|
|
46
|
+
testID?: string;
|
|
47
|
+
accessibilityHint?: string;
|
|
48
|
+
}
|
|
49
|
+
declare const FormSwitch: ({ label, value, onValueChange, disabled, description, containerStyle, testID, accessibilityHint, }: FormSwitchProps) => React.ReactElement;
|
|
50
|
+
|
|
51
|
+
export { type ChipOption, ChipSelector, type ChipSelectorProps, FormField, type FormFieldProps, FormSwitch, type FormSwitchProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextInputProps, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Reusable form field — labelled text input with optional required mark + error.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface FormFieldProps extends Omit<TextInputProps, 'style'> {
|
|
9
|
+
label: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
containerStyle?: ViewStyle;
|
|
13
|
+
}
|
|
14
|
+
declare const FormField: ({ label, required, error, containerStyle, ...textInputProps }: FormFieldProps) => React.ReactElement;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Chip/pill selector for selecting one or multiple options.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface ChipOption<T> {
|
|
21
|
+
value: T;
|
|
22
|
+
label: string;
|
|
23
|
+
}
|
|
24
|
+
interface ChipSelectorProps<T> {
|
|
25
|
+
label?: string;
|
|
26
|
+
options: Array<ChipOption<T>>;
|
|
27
|
+
value: T | T[];
|
|
28
|
+
onChange: (value: T) => void;
|
|
29
|
+
multiple?: boolean;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
containerStyle?: ViewStyle;
|
|
32
|
+
}
|
|
33
|
+
declare const ChipSelector: <T extends string | number>({ label, options, value, onChange, multiple, disabled, containerStyle, }: ChipSelectorProps<T>) => React.ReactElement;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Reusable form switch/toggle with an optional description.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
interface FormSwitchProps {
|
|
40
|
+
label: string;
|
|
41
|
+
value: boolean;
|
|
42
|
+
onValueChange: (value: boolean) => void;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
description?: string;
|
|
45
|
+
containerStyle?: ViewStyle;
|
|
46
|
+
testID?: string;
|
|
47
|
+
accessibilityHint?: string;
|
|
48
|
+
}
|
|
49
|
+
declare const FormSwitch: ({ label, value, onValueChange, disabled, description, containerStyle, testID, accessibilityHint, }: FormSwitchProps) => React.ReactElement;
|
|
50
|
+
|
|
51
|
+
export { type ChipOption, ChipSelector, type ChipSelectorProps, FormField, type FormFieldProps, FormSwitch, type FormSwitchProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactNative = require('react-native');
|
|
5
|
+
var uiFeedback = require('@dloizides/ui-feedback');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
|
|
10
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
11
|
+
|
|
12
|
+
// src/FormField/FormField.tsx
|
|
13
|
+
var CONTAINER_MARGIN_BOTTOM = 16;
|
|
14
|
+
var INPUT_PADDING = 12;
|
|
15
|
+
var INPUT_BORDER_RADIUS = 8;
|
|
16
|
+
var ERROR_FONT_SIZE = 12;
|
|
17
|
+
var styles = reactNative.StyleSheet.create({
|
|
18
|
+
container: {
|
|
19
|
+
marginBottom: CONTAINER_MARGIN_BOTTOM
|
|
20
|
+
},
|
|
21
|
+
label: {
|
|
22
|
+
marginBottom: 4,
|
|
23
|
+
fontWeight: "600"
|
|
24
|
+
},
|
|
25
|
+
input: {
|
|
26
|
+
padding: INPUT_PADDING,
|
|
27
|
+
borderRadius: INPUT_BORDER_RADIUS,
|
|
28
|
+
borderWidth: 1
|
|
29
|
+
},
|
|
30
|
+
errorText: {
|
|
31
|
+
fontSize: ERROR_FONT_SIZE,
|
|
32
|
+
marginTop: 4
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
var FormField = ({
|
|
36
|
+
label,
|
|
37
|
+
required = false,
|
|
38
|
+
error,
|
|
39
|
+
containerStyle,
|
|
40
|
+
...textInputProps
|
|
41
|
+
}) => {
|
|
42
|
+
const { theme } = uiFeedback.useUi();
|
|
43
|
+
const { colors, semantic } = theme;
|
|
44
|
+
const errorColor = semantic.error["500"];
|
|
45
|
+
const hasError = typeof error === "string" && error !== "";
|
|
46
|
+
const themeStyles = React__default.default.useMemo(() => {
|
|
47
|
+
const labelStyle = { color: colors.text };
|
|
48
|
+
const requiredMarkStyle = { color: errorColor };
|
|
49
|
+
const inputStyle = {
|
|
50
|
+
backgroundColor: colors.surface,
|
|
51
|
+
color: colors.text,
|
|
52
|
+
borderColor: hasError ? errorColor : colors.border
|
|
53
|
+
};
|
|
54
|
+
const errorTextStyle = { color: errorColor };
|
|
55
|
+
return {
|
|
56
|
+
label: labelStyle,
|
|
57
|
+
requiredMark: requiredMarkStyle,
|
|
58
|
+
input: inputStyle,
|
|
59
|
+
errorText: errorTextStyle
|
|
60
|
+
};
|
|
61
|
+
}, [colors.border, colors.surface, colors.text, errorColor, hasError]);
|
|
62
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles.container, containerStyle], children: [
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { style: [styles.label, themeStyles.label], children: [
|
|
64
|
+
label,
|
|
65
|
+
" ",
|
|
66
|
+
required ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: themeStyles.requiredMark, children: "*" }) : null
|
|
67
|
+
] }),
|
|
68
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
69
|
+
reactNative.TextInput,
|
|
70
|
+
{
|
|
71
|
+
accessibilityHint: `Enter ${label}`,
|
|
72
|
+
accessibilityLabel: label,
|
|
73
|
+
placeholderTextColor: colors.textSecondary,
|
|
74
|
+
style: [styles.input, themeStyles.input],
|
|
75
|
+
testID: "form-field-input",
|
|
76
|
+
...textInputProps
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
hasError ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles.errorText, themeStyles.errorText], children: error }) : null
|
|
80
|
+
] });
|
|
81
|
+
};
|
|
82
|
+
var TRANSPARENT_COLOR = "transparent";
|
|
83
|
+
var WHITE_COLOR = "#fff";
|
|
84
|
+
var styles2 = reactNative.StyleSheet.create({
|
|
85
|
+
label: {
|
|
86
|
+
marginBottom: 8,
|
|
87
|
+
fontWeight: "600"
|
|
88
|
+
},
|
|
89
|
+
chipContainer: {
|
|
90
|
+
flexDirection: "row",
|
|
91
|
+
flexWrap: "wrap"
|
|
92
|
+
},
|
|
93
|
+
chipWrapper: {
|
|
94
|
+
marginRight: 8,
|
|
95
|
+
marginBottom: 8
|
|
96
|
+
},
|
|
97
|
+
chip: {
|
|
98
|
+
paddingHorizontal: 12,
|
|
99
|
+
paddingVertical: 6,
|
|
100
|
+
borderRadius: 20,
|
|
101
|
+
backgroundColor: TRANSPARENT_COLOR,
|
|
102
|
+
borderWidth: 1
|
|
103
|
+
},
|
|
104
|
+
chipText: {}
|
|
105
|
+
});
|
|
106
|
+
var ChipSelector = ({
|
|
107
|
+
label,
|
|
108
|
+
options,
|
|
109
|
+
value,
|
|
110
|
+
onChange,
|
|
111
|
+
multiple = false,
|
|
112
|
+
disabled = false,
|
|
113
|
+
containerStyle
|
|
114
|
+
}) => {
|
|
115
|
+
const { theme } = uiFeedback.useUi();
|
|
116
|
+
const { colors, palette } = theme;
|
|
117
|
+
const primaryColor = palette.primary["500"];
|
|
118
|
+
const hasLabel = typeof label === "string" && label !== "";
|
|
119
|
+
const themeStyles = React__default.default.useMemo(() => {
|
|
120
|
+
const labelStyle = { color: colors.text };
|
|
121
|
+
const chipStyle = { borderColor: colors.border };
|
|
122
|
+
const chipSelectedStyle = { backgroundColor: primaryColor };
|
|
123
|
+
const chipTextStyle = { color: colors.text };
|
|
124
|
+
const chipTextSelectedStyle = { color: WHITE_COLOR };
|
|
125
|
+
return {
|
|
126
|
+
label: labelStyle,
|
|
127
|
+
chip: chipStyle,
|
|
128
|
+
chipSelected: chipSelectedStyle,
|
|
129
|
+
chipText: chipTextStyle,
|
|
130
|
+
chipTextSelected: chipTextSelectedStyle
|
|
131
|
+
};
|
|
132
|
+
}, [colors.border, colors.text, primaryColor]);
|
|
133
|
+
function isSelected(optionValue) {
|
|
134
|
+
if (multiple && Array.isArray(value))
|
|
135
|
+
return value.includes(optionValue);
|
|
136
|
+
return value === optionValue;
|
|
137
|
+
}
|
|
138
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: containerStyle, children: [
|
|
139
|
+
hasLabel ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles2.label, themeStyles.label], children: label }) : null,
|
|
140
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.chipContainer, children: options.map((option) => {
|
|
141
|
+
const selected = isSelected(option.value);
|
|
142
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
143
|
+
reactNative.TouchableOpacity,
|
|
144
|
+
{
|
|
145
|
+
accessibilityHint: `Selects ${option.label}`,
|
|
146
|
+
accessibilityLabel: option.label,
|
|
147
|
+
accessibilityRole: "button",
|
|
148
|
+
accessibilityState: { selected },
|
|
149
|
+
disabled,
|
|
150
|
+
style: styles2.chipWrapper,
|
|
151
|
+
testID: `chip-selector-chip-${String(option.value)}`,
|
|
152
|
+
onPress: () => onChange(option.value),
|
|
153
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
154
|
+
reactNative.View,
|
|
155
|
+
{
|
|
156
|
+
style: [
|
|
157
|
+
styles2.chip,
|
|
158
|
+
themeStyles.chip,
|
|
159
|
+
selected ? themeStyles.chipSelected : null
|
|
160
|
+
],
|
|
161
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles2.chipText, themeStyles.chipText, selected ? themeStyles.chipTextSelected : null], children: option.label })
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
},
|
|
165
|
+
String(option.value)
|
|
166
|
+
);
|
|
167
|
+
}) })
|
|
168
|
+
] });
|
|
169
|
+
};
|
|
170
|
+
var DESCRIPTION_FONT_SIZE = 12;
|
|
171
|
+
var styles3 = reactNative.StyleSheet.create({
|
|
172
|
+
container: {
|
|
173
|
+
flexDirection: "row",
|
|
174
|
+
justifyContent: "space-between",
|
|
175
|
+
alignItems: "center",
|
|
176
|
+
marginBottom: 12
|
|
177
|
+
},
|
|
178
|
+
textColumn: {
|
|
179
|
+
flex: 1
|
|
180
|
+
},
|
|
181
|
+
label: {
|
|
182
|
+
fontWeight: "600"
|
|
183
|
+
},
|
|
184
|
+
description: {
|
|
185
|
+
fontSize: DESCRIPTION_FONT_SIZE,
|
|
186
|
+
marginTop: 2
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
var FormSwitch = ({
|
|
190
|
+
label,
|
|
191
|
+
value,
|
|
192
|
+
onValueChange,
|
|
193
|
+
disabled = false,
|
|
194
|
+
description,
|
|
195
|
+
containerStyle,
|
|
196
|
+
testID = "form-switch",
|
|
197
|
+
accessibilityHint
|
|
198
|
+
}) => {
|
|
199
|
+
const { theme } = uiFeedback.useUi();
|
|
200
|
+
const { colors } = theme;
|
|
201
|
+
const hasDescription = typeof description === "string" && description !== "";
|
|
202
|
+
const themeStyles = React__default.default.useMemo(() => {
|
|
203
|
+
const labelStyle = { color: colors.text };
|
|
204
|
+
const descriptionStyle = { color: colors.textSecondary };
|
|
205
|
+
return { label: labelStyle, description: descriptionStyle };
|
|
206
|
+
}, [colors.text, colors.textSecondary]);
|
|
207
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
208
|
+
reactNative.View,
|
|
209
|
+
{
|
|
210
|
+
style: [
|
|
211
|
+
styles3.container,
|
|
212
|
+
containerStyle
|
|
213
|
+
],
|
|
214
|
+
children: [
|
|
215
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles3.textColumn, children: [
|
|
216
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles3.label, themeStyles.label], children: label }),
|
|
217
|
+
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles3.description, themeStyles.description], children: description }) : null
|
|
218
|
+
] }),
|
|
219
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
220
|
+
reactNative.Switch,
|
|
221
|
+
{
|
|
222
|
+
accessibilityHint: accessibilityHint ?? label,
|
|
223
|
+
accessibilityLabel: label,
|
|
224
|
+
accessibilityRole: "switch",
|
|
225
|
+
accessibilityState: { checked: value },
|
|
226
|
+
disabled,
|
|
227
|
+
testID,
|
|
228
|
+
value,
|
|
229
|
+
onValueChange
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
exports.ChipSelector = ChipSelector;
|
|
238
|
+
exports.FormField = FormField;
|
|
239
|
+
exports.FormSwitch = FormSwitch;
|
|
240
|
+
//# sourceMappingURL=index.js.map
|
|
241
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/FormField/FormField.tsx","../src/ChipSelector/ChipSelector.tsx","../src/FormSwitch/FormSwitch.tsx"],"names":["StyleSheet","useUi","React","View","jsxs","Text","jsx","TextInput","styles","TouchableOpacity","Switch"],"mappings":";;;;;;;;;;;;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EAAK,KAAA,EAAO,CAACG,QAAO,KAAA,EAAO,WAAA,CAAY,KAAK,CAAA,EAAI,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,UACtD,cAAA,mBACCF,cAAAA,CAACD,gBAAAA,EAAA,EAAK,KAAA,EAAO,CAACG,OAAAA,CAAO,WAAA,EAAa,WAAA,CAAY,WAAW,CAAA,EAAI,uBAAY,CAAA,GACvE;AAAA,SAAA,EACN,CAAA;AAAA,wBACAF,cAAAA;AAAA,UAACI,kBAAA;AAAA,UAAA;AAAA,YACC,mBAAmB,iBAAA,IAAqB,KAAA;AAAA,YACxC,kBAAA,EAAoB,KAAA;AAAA,YACpB,iBAAA,EAAkB,QAAA;AAAA,YAClB,kBAAA,EAAoB,EAAE,OAAA,EAAS,KAAA,EAAM;AAAA,YACrC,QAAA;AAAA,YACA,MAAA;AAAA,YACA,KAAA;AAAA,YACA;AAAA;AAAA;AACF;AAAA;AAAA,GACF;AAEJ","file":"index.js","sourcesContent":["/**\n * Reusable form field — labelled text input with optional required mark + error.\n */\nimport React from 'react';\n\nimport { StyleSheet, View, Text, TextInput, type TextInputProps, type TextStyle, type ViewStyle } from 'react-native';\n\nimport { useUi } from '@dloizides/ui-feedback';\n\nconst CONTAINER_MARGIN_BOTTOM = 16;\nconst INPUT_PADDING = 12;\nconst INPUT_BORDER_RADIUS = 8;\nconst ERROR_FONT_SIZE = 12;\n\nconst styles = StyleSheet.create({\n container: {\n marginBottom: CONTAINER_MARGIN_BOTTOM,\n },\n label: {\n marginBottom: 4,\n fontWeight: '600',\n },\n input: {\n padding: INPUT_PADDING,\n borderRadius: INPUT_BORDER_RADIUS,\n borderWidth: 1,\n },\n errorText: {\n fontSize: ERROR_FONT_SIZE,\n marginTop: 4,\n },\n});\n\ninterface ThemeStyles {\n label: TextStyle;\n requiredMark: TextStyle;\n input: TextStyle;\n errorText: TextStyle;\n}\n\nexport interface FormFieldProps extends Omit<TextInputProps, 'style'> {\n label: string;\n required?: boolean;\n error?: string;\n containerStyle?: ViewStyle;\n}\n\nexport const FormField = ({\n label,\n required = false,\n error,\n containerStyle,\n ...textInputProps\n}: FormFieldProps): React.ReactElement => {\n const { theme } = useUi();\n const { colors, semantic } = theme;\n const errorColor = semantic.error['500'];\n const hasError = typeof error === 'string' && error !== '';\n\n const themeStyles = React.useMemo<ThemeStyles>(() => {\n const labelStyle: TextStyle = { color: colors.text };\n const requiredMarkStyle: TextStyle = { color: errorColor };\n const inputStyle: TextStyle = {\n backgroundColor: colors.surface,\n color: colors.text,\n borderColor: hasError ? errorColor : colors.border,\n };\n const errorTextStyle: TextStyle = { color: errorColor };\n return {\n label: labelStyle,\n requiredMark: requiredMarkStyle,\n input: inputStyle,\n errorText: errorTextStyle,\n };\n }, [colors.border, colors.surface, colors.text, errorColor, hasError]);\n\n return (\n <View style={[styles.container, containerStyle]}>\n <Text style={[styles.label, themeStyles.label]}>\n {label} {required ? <Text style={themeStyles.requiredMark}>*</Text> : null}\n </Text>\n <TextInput\n accessibilityHint={`Enter ${label}`}\n accessibilityLabel={label}\n placeholderTextColor={colors.textSecondary}\n style={[styles.input, themeStyles.input]}\n testID=\"form-field-input\"\n {...textInputProps}\n />\n {hasError ? <Text style={[styles.errorText, themeStyles.errorText]}>{error}</Text> : null}\n </View>\n );\n};\n\nexport default FormField;\n","/**\n * Chip/pill selector for selecting one or multiple options.\n */\nimport React from 'react';\n\nimport { StyleSheet, View, Text, TouchableOpacity, type TextStyle, type ViewStyle } from 'react-native';\n\nimport { useUi } from '@dloizides/ui-feedback';\n\nconst TRANSPARENT_COLOR = 'transparent';\nconst WHITE_COLOR = '#fff';\n\nconst styles = StyleSheet.create({\n label: {\n marginBottom: 8,\n fontWeight: '600',\n },\n chipContainer: {\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\n chipWrapper: {\n marginRight: 8,\n marginBottom: 8,\n },\n chip: {\n paddingHorizontal: 12,\n paddingVertical: 6,\n borderRadius: 20,\n backgroundColor: TRANSPARENT_COLOR,\n borderWidth: 1,\n },\n chipText: {},\n});\n\ninterface ThemeStyles {\n label: TextStyle;\n chip: ViewStyle;\n chipSelected: ViewStyle;\n chipText: TextStyle;\n chipTextSelected: TextStyle;\n}\n\nexport interface ChipOption<T> {\n value: T;\n label: string;\n}\n\nexport interface ChipSelectorProps<T> {\n label?: string;\n options: Array<ChipOption<T>>;\n value: T | T[];\n onChange: (value: T) => void;\n multiple?: boolean;\n disabled?: boolean;\n containerStyle?: ViewStyle;\n}\n\nexport const ChipSelector = <T extends string | number>({\n label,\n options,\n value,\n onChange,\n multiple = false,\n disabled = false,\n containerStyle,\n}: ChipSelectorProps<T>): React.ReactElement => {\n const { theme } = useUi();\n const { colors, palette } = theme;\n const primaryColor = palette.primary['500'];\n const hasLabel = typeof label === 'string' && label !== '';\n\n const themeStyles = React.useMemo<ThemeStyles>(() => {\n const labelStyle: TextStyle = { color: colors.text };\n const chipStyle: ViewStyle = { borderColor: colors.border };\n const chipSelectedStyle: ViewStyle = { backgroundColor: primaryColor };\n const chipTextStyle: TextStyle = { color: colors.text };\n const chipTextSelectedStyle: TextStyle = { color: WHITE_COLOR };\n return {\n label: labelStyle,\n chip: chipStyle,\n chipSelected: chipSelectedStyle,\n chipText: chipTextStyle,\n chipTextSelected: chipTextSelectedStyle,\n };\n }, [colors.border, colors.text, primaryColor]);\n\n function isSelected(optionValue: T): boolean {\n if (multiple && Array.isArray(value))\n return value.includes(optionValue);\n\n return value === optionValue;\n }\n\n return (\n <View style={containerStyle}>\n {hasLabel ? <Text style={[styles.label, themeStyles.label]}>{label}</Text> : null}\n <View style={styles.chipContainer}>\n {options.map((option) => {\n const selected = isSelected(option.value);\n return (\n <TouchableOpacity\n key={String(option.value)}\n accessibilityHint={`Selects ${option.label}`}\n accessibilityLabel={option.label}\n accessibilityRole=\"button\"\n accessibilityState={{ selected }}\n disabled={disabled}\n style={styles.chipWrapper}\n testID={`chip-selector-chip-${String(option.value)}`}\n onPress={() => onChange(option.value)}\n >\n <View\n style={[\n styles.chip,\n themeStyles.chip,\n selected ? themeStyles.chipSelected : null,\n ]}\n >\n <Text style={[styles.chipText, themeStyles.chipText, selected ? themeStyles.chipTextSelected : null]}>\n {option.label}\n </Text>\n </View>\n </TouchableOpacity>\n );\n })}\n </View>\n </View>\n );\n};\n\nexport default ChipSelector;\n","/**\n * Reusable form switch/toggle with an optional description.\n */\nimport React from 'react';\n\nimport { StyleSheet, View, Text, Switch, type TextStyle, type ViewStyle } from 'react-native';\n\nimport { useUi } from '@dloizides/ui-feedback';\n\nconst DESCRIPTION_FONT_SIZE = 12;\n\nconst styles = StyleSheet.create({\n container: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n marginBottom: 12,\n },\n textColumn: {\n flex: 1,\n },\n label: {\n fontWeight: '600',\n },\n description: {\n fontSize: DESCRIPTION_FONT_SIZE,\n marginTop: 2,\n },\n});\n\ninterface ThemeStyles {\n label: TextStyle;\n description: TextStyle;\n}\n\nexport interface FormSwitchProps {\n label: string;\n value: boolean;\n onValueChange: (value: boolean) => void;\n disabled?: boolean;\n description?: string;\n containerStyle?: ViewStyle;\n testID?: string;\n accessibilityHint?: string;\n}\n\nexport const FormSwitch = ({\n label,\n value,\n onValueChange,\n disabled = false,\n description,\n containerStyle,\n testID = 'form-switch',\n accessibilityHint,\n}: FormSwitchProps): React.ReactElement => {\n const { theme } = useUi();\n const { colors } = theme;\n const hasDescription = typeof description === 'string' && description !== '';\n\n const themeStyles = React.useMemo<ThemeStyles>(() => {\n const labelStyle: TextStyle = { color: colors.text };\n const descriptionStyle: TextStyle = { color: colors.textSecondary };\n return { label: labelStyle, description: descriptionStyle };\n }, [colors.text, colors.textSecondary]);\n\n return (\n <View\n style={[\n styles.container,\n containerStyle,\n ]}\n >\n <View style={styles.textColumn}>\n <Text style={[styles.label, themeStyles.label]}>{label}</Text>\n {hasDescription ? (\n <Text style={[styles.description, themeStyles.description]}>{description}</Text>\n ) : null}\n </View>\n <Switch\n accessibilityHint={accessibilityHint ?? label}\n accessibilityLabel={label}\n accessibilityRole=\"switch\"\n accessibilityState={{ checked: value }}\n disabled={disabled}\n testID={testID}\n value={value}\n onValueChange={onValueChange}\n />\n </View>\n );\n};\n\nexport default FormSwitch;\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, View, Text, TextInput, TouchableOpacity, Switch } from 'react-native';
|
|
3
|
+
import { useUi } from '@dloizides/ui-feedback';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/FormField/FormField.tsx
|
|
7
|
+
var CONTAINER_MARGIN_BOTTOM = 16;
|
|
8
|
+
var INPUT_PADDING = 12;
|
|
9
|
+
var INPUT_BORDER_RADIUS = 8;
|
|
10
|
+
var ERROR_FONT_SIZE = 12;
|
|
11
|
+
var styles = StyleSheet.create({
|
|
12
|
+
container: {
|
|
13
|
+
marginBottom: CONTAINER_MARGIN_BOTTOM
|
|
14
|
+
},
|
|
15
|
+
label: {
|
|
16
|
+
marginBottom: 4,
|
|
17
|
+
fontWeight: "600"
|
|
18
|
+
},
|
|
19
|
+
input: {
|
|
20
|
+
padding: INPUT_PADDING,
|
|
21
|
+
borderRadius: INPUT_BORDER_RADIUS,
|
|
22
|
+
borderWidth: 1
|
|
23
|
+
},
|
|
24
|
+
errorText: {
|
|
25
|
+
fontSize: ERROR_FONT_SIZE,
|
|
26
|
+
marginTop: 4
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var FormField = ({
|
|
30
|
+
label,
|
|
31
|
+
required = false,
|
|
32
|
+
error,
|
|
33
|
+
containerStyle,
|
|
34
|
+
...textInputProps
|
|
35
|
+
}) => {
|
|
36
|
+
const { theme } = useUi();
|
|
37
|
+
const { colors, semantic } = theme;
|
|
38
|
+
const errorColor = semantic.error["500"];
|
|
39
|
+
const hasError = typeof error === "string" && error !== "";
|
|
40
|
+
const themeStyles = React.useMemo(() => {
|
|
41
|
+
const labelStyle = { color: colors.text };
|
|
42
|
+
const requiredMarkStyle = { color: errorColor };
|
|
43
|
+
const inputStyle = {
|
|
44
|
+
backgroundColor: colors.surface,
|
|
45
|
+
color: colors.text,
|
|
46
|
+
borderColor: hasError ? errorColor : colors.border
|
|
47
|
+
};
|
|
48
|
+
const errorTextStyle = { color: errorColor };
|
|
49
|
+
return {
|
|
50
|
+
label: labelStyle,
|
|
51
|
+
requiredMark: requiredMarkStyle,
|
|
52
|
+
input: inputStyle,
|
|
53
|
+
errorText: errorTextStyle
|
|
54
|
+
};
|
|
55
|
+
}, [colors.border, colors.surface, colors.text, errorColor, hasError]);
|
|
56
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles.container, containerStyle], children: [
|
|
57
|
+
/* @__PURE__ */ jsxs(Text, { style: [styles.label, themeStyles.label], children: [
|
|
58
|
+
label,
|
|
59
|
+
" ",
|
|
60
|
+
required ? /* @__PURE__ */ jsx(Text, { style: themeStyles.requiredMark, children: "*" }) : null
|
|
61
|
+
] }),
|
|
62
|
+
/* @__PURE__ */ jsx(
|
|
63
|
+
TextInput,
|
|
64
|
+
{
|
|
65
|
+
accessibilityHint: `Enter ${label}`,
|
|
66
|
+
accessibilityLabel: label,
|
|
67
|
+
placeholderTextColor: colors.textSecondary,
|
|
68
|
+
style: [styles.input, themeStyles.input],
|
|
69
|
+
testID: "form-field-input",
|
|
70
|
+
...textInputProps
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
hasError ? /* @__PURE__ */ jsx(Text, { style: [styles.errorText, themeStyles.errorText], children: error }) : null
|
|
74
|
+
] });
|
|
75
|
+
};
|
|
76
|
+
var TRANSPARENT_COLOR = "transparent";
|
|
77
|
+
var WHITE_COLOR = "#fff";
|
|
78
|
+
var styles2 = StyleSheet.create({
|
|
79
|
+
label: {
|
|
80
|
+
marginBottom: 8,
|
|
81
|
+
fontWeight: "600"
|
|
82
|
+
},
|
|
83
|
+
chipContainer: {
|
|
84
|
+
flexDirection: "row",
|
|
85
|
+
flexWrap: "wrap"
|
|
86
|
+
},
|
|
87
|
+
chipWrapper: {
|
|
88
|
+
marginRight: 8,
|
|
89
|
+
marginBottom: 8
|
|
90
|
+
},
|
|
91
|
+
chip: {
|
|
92
|
+
paddingHorizontal: 12,
|
|
93
|
+
paddingVertical: 6,
|
|
94
|
+
borderRadius: 20,
|
|
95
|
+
backgroundColor: TRANSPARENT_COLOR,
|
|
96
|
+
borderWidth: 1
|
|
97
|
+
},
|
|
98
|
+
chipText: {}
|
|
99
|
+
});
|
|
100
|
+
var ChipSelector = ({
|
|
101
|
+
label,
|
|
102
|
+
options,
|
|
103
|
+
value,
|
|
104
|
+
onChange,
|
|
105
|
+
multiple = false,
|
|
106
|
+
disabled = false,
|
|
107
|
+
containerStyle
|
|
108
|
+
}) => {
|
|
109
|
+
const { theme } = useUi();
|
|
110
|
+
const { colors, palette } = theme;
|
|
111
|
+
const primaryColor = palette.primary["500"];
|
|
112
|
+
const hasLabel = typeof label === "string" && label !== "";
|
|
113
|
+
const themeStyles = React.useMemo(() => {
|
|
114
|
+
const labelStyle = { color: colors.text };
|
|
115
|
+
const chipStyle = { borderColor: colors.border };
|
|
116
|
+
const chipSelectedStyle = { backgroundColor: primaryColor };
|
|
117
|
+
const chipTextStyle = { color: colors.text };
|
|
118
|
+
const chipTextSelectedStyle = { color: WHITE_COLOR };
|
|
119
|
+
return {
|
|
120
|
+
label: labelStyle,
|
|
121
|
+
chip: chipStyle,
|
|
122
|
+
chipSelected: chipSelectedStyle,
|
|
123
|
+
chipText: chipTextStyle,
|
|
124
|
+
chipTextSelected: chipTextSelectedStyle
|
|
125
|
+
};
|
|
126
|
+
}, [colors.border, colors.text, primaryColor]);
|
|
127
|
+
function isSelected(optionValue) {
|
|
128
|
+
if (multiple && Array.isArray(value))
|
|
129
|
+
return value.includes(optionValue);
|
|
130
|
+
return value === optionValue;
|
|
131
|
+
}
|
|
132
|
+
return /* @__PURE__ */ jsxs(View, { style: containerStyle, children: [
|
|
133
|
+
hasLabel ? /* @__PURE__ */ jsx(Text, { style: [styles2.label, themeStyles.label], children: label }) : null,
|
|
134
|
+
/* @__PURE__ */ jsx(View, { style: styles2.chipContainer, children: options.map((option) => {
|
|
135
|
+
const selected = isSelected(option.value);
|
|
136
|
+
return /* @__PURE__ */ jsx(
|
|
137
|
+
TouchableOpacity,
|
|
138
|
+
{
|
|
139
|
+
accessibilityHint: `Selects ${option.label}`,
|
|
140
|
+
accessibilityLabel: option.label,
|
|
141
|
+
accessibilityRole: "button",
|
|
142
|
+
accessibilityState: { selected },
|
|
143
|
+
disabled,
|
|
144
|
+
style: styles2.chipWrapper,
|
|
145
|
+
testID: `chip-selector-chip-${String(option.value)}`,
|
|
146
|
+
onPress: () => onChange(option.value),
|
|
147
|
+
children: /* @__PURE__ */ jsx(
|
|
148
|
+
View,
|
|
149
|
+
{
|
|
150
|
+
style: [
|
|
151
|
+
styles2.chip,
|
|
152
|
+
themeStyles.chip,
|
|
153
|
+
selected ? themeStyles.chipSelected : null
|
|
154
|
+
],
|
|
155
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles2.chipText, themeStyles.chipText, selected ? themeStyles.chipTextSelected : null], children: option.label })
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
},
|
|
159
|
+
String(option.value)
|
|
160
|
+
);
|
|
161
|
+
}) })
|
|
162
|
+
] });
|
|
163
|
+
};
|
|
164
|
+
var DESCRIPTION_FONT_SIZE = 12;
|
|
165
|
+
var styles3 = StyleSheet.create({
|
|
166
|
+
container: {
|
|
167
|
+
flexDirection: "row",
|
|
168
|
+
justifyContent: "space-between",
|
|
169
|
+
alignItems: "center",
|
|
170
|
+
marginBottom: 12
|
|
171
|
+
},
|
|
172
|
+
textColumn: {
|
|
173
|
+
flex: 1
|
|
174
|
+
},
|
|
175
|
+
label: {
|
|
176
|
+
fontWeight: "600"
|
|
177
|
+
},
|
|
178
|
+
description: {
|
|
179
|
+
fontSize: DESCRIPTION_FONT_SIZE,
|
|
180
|
+
marginTop: 2
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
var FormSwitch = ({
|
|
184
|
+
label,
|
|
185
|
+
value,
|
|
186
|
+
onValueChange,
|
|
187
|
+
disabled = false,
|
|
188
|
+
description,
|
|
189
|
+
containerStyle,
|
|
190
|
+
testID = "form-switch",
|
|
191
|
+
accessibilityHint
|
|
192
|
+
}) => {
|
|
193
|
+
const { theme } = useUi();
|
|
194
|
+
const { colors } = theme;
|
|
195
|
+
const hasDescription = typeof description === "string" && description !== "";
|
|
196
|
+
const themeStyles = React.useMemo(() => {
|
|
197
|
+
const labelStyle = { color: colors.text };
|
|
198
|
+
const descriptionStyle = { color: colors.textSecondary };
|
|
199
|
+
return { label: labelStyle, description: descriptionStyle };
|
|
200
|
+
}, [colors.text, colors.textSecondary]);
|
|
201
|
+
return /* @__PURE__ */ jsxs(
|
|
202
|
+
View,
|
|
203
|
+
{
|
|
204
|
+
style: [
|
|
205
|
+
styles3.container,
|
|
206
|
+
containerStyle
|
|
207
|
+
],
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ jsxs(View, { style: styles3.textColumn, children: [
|
|
210
|
+
/* @__PURE__ */ jsx(Text, { style: [styles3.label, themeStyles.label], children: label }),
|
|
211
|
+
hasDescription ? /* @__PURE__ */ jsx(Text, { style: [styles3.description, themeStyles.description], children: description }) : null
|
|
212
|
+
] }),
|
|
213
|
+
/* @__PURE__ */ jsx(
|
|
214
|
+
Switch,
|
|
215
|
+
{
|
|
216
|
+
accessibilityHint: accessibilityHint ?? label,
|
|
217
|
+
accessibilityLabel: label,
|
|
218
|
+
accessibilityRole: "switch",
|
|
219
|
+
accessibilityState: { checked: value },
|
|
220
|
+
disabled,
|
|
221
|
+
testID,
|
|
222
|
+
value,
|
|
223
|
+
onValueChange
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export { ChipSelector, FormField, FormSwitch };
|
|
232
|
+
//# sourceMappingURL=index.mjs.map
|
|
233
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/FormField/FormField.tsx","../src/ChipSelector/ChipSelector.tsx","../src/FormSwitch/FormSwitch.tsx"],"names":["styles","StyleSheet","useUi","React","jsxs","View","jsx","Text"],"mappings":";;;;;;AASA,IAAM,uBAAA,GAA0B,EAAA;AAChC,IAAM,aAAA,GAAgB,EAAA;AACtB,IAAM,mBAAA,GAAsB,CAAA;AAC5B,IAAM,eAAA,GAAkB,EAAA;AAExB,IAAM,MAAA,GAAS,WAAW,MAAA,CAAO;AAAA,EAC/B,SAAA,EAAW;AAAA,IACT,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,KAAA,EAAO;AAAA,IACL,YAAA,EAAc,CAAA;AAAA,IACd,UAAA,EAAY;AAAA,GACd;AAAA,EACA,KAAA,EAAO;AAAA,IACL,OAAA,EAAS,aAAA;AAAA,IACT,YAAA,EAAc,mBAAA;AAAA,IACd,WAAA,EAAa;AAAA,GACf;AAAA,EACA,SAAA,EAAW;AAAA,IACT,QAAA,EAAU,eAAA;AAAA,IACV,SAAA,EAAW;AAAA;AAEf,CAAC,CAAA;AAgBM,IAAM,YAAY,CAAC;AAAA,EACxB,KAAA;AAAA,EACA,QAAA,GAAW,KAAA;AAAA,EACX,KAAA;AAAA,EACA,cAAA;AAAA,EACA,GAAG;AACL,CAAA,KAA0C;AACxC,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,KAAA,EAAM;AACxB,EAAA,MAAM,EAAE,MAAA,EAAQ,QAAA,EAAS,GAAI,KAAA;AAC7B,EAAA,MAAM,UAAA,GAAa,QAAA,CAAS,KAAA,CAAM,KAAK,CAAA;AACvC,EAAA,MAAM,QAAA,GAAW,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,EAAA;AAExD,EAAA,MAAM,WAAA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AA,IAAA;AAAA,MACC,KAAA,EAAO;AAAA,QACLL,OAAAA,CAAO,SAAA;AAAA,QACP;AAAA,OACF;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAAI,IAAAA,CAACC,IAAAA,EAAA,EAAK,KAAA,EAAOL,QAAO,UAAA,EAClB,QAAA,EAAA;AAAA,0BAAAM,GAAAA,CAACC,IAAAA,EAAA,EAAK,KAAA,EAAO,CAACP,QAAO,KAAA,EAAO,WAAA,CAAY,KAAK,CAAA,EAAI,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,UACtD,cAAA,mBACCM,GAAAA,CAACC,IAAAA,EAAA,EAAK,KAAA,EAAO,CAACP,OAAAA,CAAO,WAAA,EAAa,WAAA,CAAY,WAAW,CAAA,EAAI,uBAAY,CAAA,GACvE;AAAA,SAAA,EACN,CAAA;AAAA,wBACAM,GAAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,mBAAmB,iBAAA,IAAqB,KAAA;AAAA,YACxC,kBAAA,EAAoB,KAAA;AAAA,YACpB,iBAAA,EAAkB,QAAA;AAAA,YAClB,kBAAA,EAAoB,EAAE,OAAA,EAAS,KAAA,EAAM;AAAA,YACrC,QAAA;AAAA,YACA,MAAA;AAAA,YACA,KAAA;AAAA,YACA;AAAA;AAAA;AACF;AAAA;AAAA,GACF;AAEJ","file":"index.mjs","sourcesContent":["/**\n * Reusable form field — labelled text input with optional required mark + error.\n */\nimport React from 'react';\n\nimport { StyleSheet, View, Text, TextInput, type TextInputProps, type TextStyle, type ViewStyle } from 'react-native';\n\nimport { useUi } from '@dloizides/ui-feedback';\n\nconst CONTAINER_MARGIN_BOTTOM = 16;\nconst INPUT_PADDING = 12;\nconst INPUT_BORDER_RADIUS = 8;\nconst ERROR_FONT_SIZE = 12;\n\nconst styles = StyleSheet.create({\n container: {\n marginBottom: CONTAINER_MARGIN_BOTTOM,\n },\n label: {\n marginBottom: 4,\n fontWeight: '600',\n },\n input: {\n padding: INPUT_PADDING,\n borderRadius: INPUT_BORDER_RADIUS,\n borderWidth: 1,\n },\n errorText: {\n fontSize: ERROR_FONT_SIZE,\n marginTop: 4,\n },\n});\n\ninterface ThemeStyles {\n label: TextStyle;\n requiredMark: TextStyle;\n input: TextStyle;\n errorText: TextStyle;\n}\n\nexport interface FormFieldProps extends Omit<TextInputProps, 'style'> {\n label: string;\n required?: boolean;\n error?: string;\n containerStyle?: ViewStyle;\n}\n\nexport const FormField = ({\n label,\n required = false,\n error,\n containerStyle,\n ...textInputProps\n}: FormFieldProps): React.ReactElement => {\n const { theme } = useUi();\n const { colors, semantic } = theme;\n const errorColor = semantic.error['500'];\n const hasError = typeof error === 'string' && error !== '';\n\n const themeStyles = React.useMemo<ThemeStyles>(() => {\n const labelStyle: TextStyle = { color: colors.text };\n const requiredMarkStyle: TextStyle = { color: errorColor };\n const inputStyle: TextStyle = {\n backgroundColor: colors.surface,\n color: colors.text,\n borderColor: hasError ? errorColor : colors.border,\n };\n const errorTextStyle: TextStyle = { color: errorColor };\n return {\n label: labelStyle,\n requiredMark: requiredMarkStyle,\n input: inputStyle,\n errorText: errorTextStyle,\n };\n }, [colors.border, colors.surface, colors.text, errorColor, hasError]);\n\n return (\n <View style={[styles.container, containerStyle]}>\n <Text style={[styles.label, themeStyles.label]}>\n {label} {required ? <Text style={themeStyles.requiredMark}>*</Text> : null}\n </Text>\n <TextInput\n accessibilityHint={`Enter ${label}`}\n accessibilityLabel={label}\n placeholderTextColor={colors.textSecondary}\n style={[styles.input, themeStyles.input]}\n testID=\"form-field-input\"\n {...textInputProps}\n />\n {hasError ? <Text style={[styles.errorText, themeStyles.errorText]}>{error}</Text> : null}\n </View>\n );\n};\n\nexport default FormField;\n","/**\n * Chip/pill selector for selecting one or multiple options.\n */\nimport React from 'react';\n\nimport { StyleSheet, View, Text, TouchableOpacity, type TextStyle, type ViewStyle } from 'react-native';\n\nimport { useUi } from '@dloizides/ui-feedback';\n\nconst TRANSPARENT_COLOR = 'transparent';\nconst WHITE_COLOR = '#fff';\n\nconst styles = StyleSheet.create({\n label: {\n marginBottom: 8,\n fontWeight: '600',\n },\n chipContainer: {\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\n chipWrapper: {\n marginRight: 8,\n marginBottom: 8,\n },\n chip: {\n paddingHorizontal: 12,\n paddingVertical: 6,\n borderRadius: 20,\n backgroundColor: TRANSPARENT_COLOR,\n borderWidth: 1,\n },\n chipText: {},\n});\n\ninterface ThemeStyles {\n label: TextStyle;\n chip: ViewStyle;\n chipSelected: ViewStyle;\n chipText: TextStyle;\n chipTextSelected: TextStyle;\n}\n\nexport interface ChipOption<T> {\n value: T;\n label: string;\n}\n\nexport interface ChipSelectorProps<T> {\n label?: string;\n options: Array<ChipOption<T>>;\n value: T | T[];\n onChange: (value: T) => void;\n multiple?: boolean;\n disabled?: boolean;\n containerStyle?: ViewStyle;\n}\n\nexport const ChipSelector = <T extends string | number>({\n label,\n options,\n value,\n onChange,\n multiple = false,\n disabled = false,\n containerStyle,\n}: ChipSelectorProps<T>): React.ReactElement => {\n const { theme } = useUi();\n const { colors, palette } = theme;\n const primaryColor = palette.primary['500'];\n const hasLabel = typeof label === 'string' && label !== '';\n\n const themeStyles = React.useMemo<ThemeStyles>(() => {\n const labelStyle: TextStyle = { color: colors.text };\n const chipStyle: ViewStyle = { borderColor: colors.border };\n const chipSelectedStyle: ViewStyle = { backgroundColor: primaryColor };\n const chipTextStyle: TextStyle = { color: colors.text };\n const chipTextSelectedStyle: TextStyle = { color: WHITE_COLOR };\n return {\n label: labelStyle,\n chip: chipStyle,\n chipSelected: chipSelectedStyle,\n chipText: chipTextStyle,\n chipTextSelected: chipTextSelectedStyle,\n };\n }, [colors.border, colors.text, primaryColor]);\n\n function isSelected(optionValue: T): boolean {\n if (multiple && Array.isArray(value))\n return value.includes(optionValue);\n\n return value === optionValue;\n }\n\n return (\n <View style={containerStyle}>\n {hasLabel ? <Text style={[styles.label, themeStyles.label]}>{label}</Text> : null}\n <View style={styles.chipContainer}>\n {options.map((option) => {\n const selected = isSelected(option.value);\n return (\n <TouchableOpacity\n key={String(option.value)}\n accessibilityHint={`Selects ${option.label}`}\n accessibilityLabel={option.label}\n accessibilityRole=\"button\"\n accessibilityState={{ selected }}\n disabled={disabled}\n style={styles.chipWrapper}\n testID={`chip-selector-chip-${String(option.value)}`}\n onPress={() => onChange(option.value)}\n >\n <View\n style={[\n styles.chip,\n themeStyles.chip,\n selected ? themeStyles.chipSelected : null,\n ]}\n >\n <Text style={[styles.chipText, themeStyles.chipText, selected ? themeStyles.chipTextSelected : null]}>\n {option.label}\n </Text>\n </View>\n </TouchableOpacity>\n );\n })}\n </View>\n </View>\n );\n};\n\nexport default ChipSelector;\n","/**\n * Reusable form switch/toggle with an optional description.\n */\nimport React from 'react';\n\nimport { StyleSheet, View, Text, Switch, type TextStyle, type ViewStyle } from 'react-native';\n\nimport { useUi } from '@dloizides/ui-feedback';\n\nconst DESCRIPTION_FONT_SIZE = 12;\n\nconst styles = StyleSheet.create({\n container: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n marginBottom: 12,\n },\n textColumn: {\n flex: 1,\n },\n label: {\n fontWeight: '600',\n },\n description: {\n fontSize: DESCRIPTION_FONT_SIZE,\n marginTop: 2,\n },\n});\n\ninterface ThemeStyles {\n label: TextStyle;\n description: TextStyle;\n}\n\nexport interface FormSwitchProps {\n label: string;\n value: boolean;\n onValueChange: (value: boolean) => void;\n disabled?: boolean;\n description?: string;\n containerStyle?: ViewStyle;\n testID?: string;\n accessibilityHint?: string;\n}\n\nexport const FormSwitch = ({\n label,\n value,\n onValueChange,\n disabled = false,\n description,\n containerStyle,\n testID = 'form-switch',\n accessibilityHint,\n}: FormSwitchProps): React.ReactElement => {\n const { theme } = useUi();\n const { colors } = theme;\n const hasDescription = typeof description === 'string' && description !== '';\n\n const themeStyles = React.useMemo<ThemeStyles>(() => {\n const labelStyle: TextStyle = { color: colors.text };\n const descriptionStyle: TextStyle = { color: colors.textSecondary };\n return { label: labelStyle, description: descriptionStyle };\n }, [colors.text, colors.textSecondary]);\n\n return (\n <View\n style={[\n styles.container,\n containerStyle,\n ]}\n >\n <View style={styles.textColumn}>\n <Text style={[styles.label, themeStyles.label]}>{label}</Text>\n {hasDescription ? (\n <Text style={[styles.description, themeStyles.description]}>{description}</Text>\n ) : null}\n </View>\n <Switch\n accessibilityHint={accessibilityHint ?? label}\n accessibilityLabel={label}\n accessibilityRole=\"switch\"\n accessibilityState={{ checked: value }}\n disabled={disabled}\n testID={testID}\n value={value}\n onValueChange={onValueChange}\n />\n </View>\n );\n};\n\nexport default FormSwitch;\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dloizides/ui-forms",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Themable, brand-agnostic React Native (RN-web) form components — FormField, ChipSelector, FormSwitch — sharing the @dloizides/ui-feedback UI context. Part of the dloizides.com shared UI kit.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"react-native",
|
|
8
|
+
"react-native-web",
|
|
9
|
+
"ui",
|
|
10
|
+
"forms",
|
|
11
|
+
"form-field",
|
|
12
|
+
"dloizides"
|
|
13
|
+
],
|
|
14
|
+
"author": "dloizides",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/openmindednewby/ui-forms.git"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/openmindednewby/ui-forms#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/openmindednewby/ui-forms/issues"
|
|
23
|
+
},
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"module": "./dist/index.mjs",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"react-native": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"browser": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"require": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"default": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/index.d.mts",
|
|
43
|
+
"default": "./dist/index.mjs"
|
|
44
|
+
},
|
|
45
|
+
"default": {
|
|
46
|
+
"types": "./dist/index.d.ts",
|
|
47
|
+
"default": "./dist/index.js"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist",
|
|
53
|
+
"README.md",
|
|
54
|
+
"CHANGELOG.md"
|
|
55
|
+
],
|
|
56
|
+
"sideEffects": false,
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=18.0.0"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "rimraf dist && tsup",
|
|
62
|
+
"build:watch": "tsup --watch",
|
|
63
|
+
"test": "jest",
|
|
64
|
+
"test:watch": "jest --watch",
|
|
65
|
+
"test:coverage": "jest --coverage",
|
|
66
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
67
|
+
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
68
|
+
"typecheck": "tsc --noEmit",
|
|
69
|
+
"clean": "rimraf dist",
|
|
70
|
+
"security:audit": "npm audit --audit-level=high",
|
|
71
|
+
"deps:outdated": "npm outdated || exit 0",
|
|
72
|
+
"deps:unused": "npx depcheck --ignores \"@types/jest,@types/node,@types/react,@types/react-dom,rimraf,react-native,react-native-web\"",
|
|
73
|
+
"deps:licenses": "npx license-checker --onlyAllow \"MIT;Apache-2.0;ISC;BSD-2-Clause;BSD-3-Clause;0BSD;Unlicense;CC0-1.0\"",
|
|
74
|
+
"deps:health": "npm run deps:outdated && npm run deps:unused",
|
|
75
|
+
"prepublishOnly": "npm run clean && npm run build && npm run test",
|
|
76
|
+
"version": "npm run build"
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"@dloizides/ui-feedback": ">=1.1.0",
|
|
80
|
+
"react": ">=18.0.0",
|
|
81
|
+
"react-native": ">=0.74.0"
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@dloizides/ui-feedback": "^1.1.0",
|
|
85
|
+
"@testing-library/dom": "^10.4.0",
|
|
86
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
87
|
+
"@testing-library/react": "^16.1.0",
|
|
88
|
+
"@types/jest": "^29.5.0",
|
|
89
|
+
"@types/node": "^20.19.32",
|
|
90
|
+
"@types/react": "^19.0.0",
|
|
91
|
+
"@types/react-dom": "^19.0.0",
|
|
92
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
93
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
94
|
+
"eslint": "^8.57.0",
|
|
95
|
+
"eslint-plugin-react": "^7.34.0",
|
|
96
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
97
|
+
"jest": "^29.7.0",
|
|
98
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
99
|
+
"react": "^19.2.4",
|
|
100
|
+
"react-dom": "^19.2.4",
|
|
101
|
+
"react-native": "0.81.5",
|
|
102
|
+
"react-native-web": "^0.21.0",
|
|
103
|
+
"rimraf": "^5.0.0",
|
|
104
|
+
"ts-jest": "^29.1.0",
|
|
105
|
+
"tsup": "^8.0.0",
|
|
106
|
+
"typescript": "^5.4.0"
|
|
107
|
+
}
|
|
108
|
+
}
|