@engagebay/engagebay-form-module 1.0.2-beta.6 → 1.0.2-beta.8

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 CHANGED
@@ -124,22 +124,3 @@ const fieldSchema: FormFieldSchema = {
124
124
 
125
125
  - **`FormFieldPatternsImpl`**
126
126
  Class providing validation patterns and messages for fields (e.g., `REQUIRED`, `EMAIL`, `URL`).
127
-
128
- ---
129
-
130
- ## Context and providers (this package only)
131
-
132
- These contexts are used **inside this package** (and by other packages in the eb-ui-components repo that depend on it). Consuming applications (other projects) have their own context trees and may wrap this package differently.
133
-
134
- - **FormContext** — Provided by `<Form>`. Required for all field components used via `FormField` / `FormFields` (they use `useContext(FormContext)`).
135
- - **AxiosConfigProvider** — Optional. Only needed for components that call APIs (e.g. dynamic options). Use `useAxiosConfig()` or `useAxiosConfigOptional()`.
136
-
137
- ---
138
-
139
- ## Implementing base components (this package)
140
-
141
- When adding or changing form field components **in this package**:
142
-
143
- - **Form-context components** — Must run inside `<Form>`. Use `useContext(FormContext)` for `register`, `setValue`, `control`, `errors`, etc. Register the component in `FormFieldUtils.ts` and export it from the package’s main entry (`index.js`).
144
- - **Context-free components** — If a component does not need form or API context, note it in JSDoc (e.g. “Does not require FormContext”).
145
- - **New contexts** — If you add a new React context in this package, document it in this README and list which components use it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engagebay/engagebay-form-module",
3
- "version": "1.0.2-beta.6",
3
+ "version": "1.0.2-beta.8",
4
4
  "description": "Provide base form components to reacho",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -35,14 +35,28 @@ const DatePicker: React.FC<FormFieldComponentPropSchema> = (
35
35
  let hookProps = formContext.register(props.fieldConfig.name, registerOptions);
36
36
 
37
37
  function getInput() {
38
+ const rawStart =
39
+ initialDate?.startDate ||
40
+ props.fieldConfig.defaultValue ||
41
+ "";
42
+ const rawEnd =
43
+ initialDate?.endDate ||
44
+ props.fieldConfig.defaultValue ||
45
+ "";
46
+ const toDate = (v: string | Date | null | undefined): Date | null => {
47
+ if (v == null || v === "") return null;
48
+ return moment(v).isValid() ? moment(v).toDate() : null;
49
+ };
50
+ const value = {
51
+ startDate: toDate(rawStart),
52
+ endDate: toDate(rawEnd),
53
+ };
54
+ // Calendar opens on selected date's month/year (must be a Date instance)
55
+ const startFrom = value.startDate instanceof Date ? value.startDate : new Date();
38
56
  return (
39
57
  <Datepicker
40
- value={
41
- initialDate || {
42
- startDate: props.fieldConfig.defaultValue,
43
- endDate: props.fieldConfig.defaultValue,
44
- }
45
- }
58
+ value={value}
59
+ startFrom={startFrom}
46
60
  {...hookProps}
47
61
  placeholder={
48
62
  props.fieldConfig.placeholder
@@ -53,13 +67,7 @@ const DatePicker: React.FC<FormFieldComponentPropSchema> = (
53
67
  popoverDirection="down"
54
68
  useRange={false}
55
69
  inputName={props.fieldConfig.name}
56
- key={
57
- props.fieldConfig.name +
58
- "_" +
59
- initialDate.startDate +
60
- "_" +
61
- initialDate.endDate
62
- }
70
+ key={props.fieldConfig.name + "_" + rawStart + "_" + rawEnd}
63
71
  containerClassName={"relative"}
64
72
  minDate={props.fieldConfig.minDate}
65
73
  maxDate={props.fieldConfig.maxDate}
@@ -86,7 +86,7 @@ const Typeahead2: React.FC<FormFieldComponentPropSchema> = (
86
86
  const controller = new AbortController();
87
87
  abortControllerRef.current = controller;
88
88
 
89
- if (!_query || _query.length < 3) {
89
+ if (!_query || (props.fieldConfig.allowedMinQueryLength && _query.length < props.fieldConfig.allowedMinQueryLength) || _query.length < 3) {
90
90
  setListOptions([]);
91
91
  setLoading(false);
92
92
  return;
@@ -136,6 +136,7 @@ export type FormFieldSchema = {
136
136
  icon?: ReactNode;
137
137
  outputFormat?: OutputFormatType;
138
138
  isMultiple?: boolean;
139
+ allowedMinQueryLength?: number;
139
140
  children?: FormFieldSchema[];
140
141
  defaultOptions?: FieldOptionsSchema[];
141
142
  optionsConfig?: OptionMappingConfig;