@axinom/mosaic-ui 0.79.0-rc.11 → 0.79.0-rc.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/dist/cjs/components/FormElements/CustomTags/CustomTags.d.ts +28 -0
- package/dist/cjs/components/FormElements/CustomTags/CustomTags.d.ts.map +1 -1
- package/dist/cjs/components/FormElements/CustomTags/CustomTagsField.d.ts +15 -0
- package/dist/cjs/components/FormElements/CustomTags/CustomTagsField.d.ts.map +1 -1
- package/dist/cjs/components/FormElements/index.d.ts +1 -1
- package/dist/cjs/components/FormElements/index.d.ts.map +1 -1
- package/dist/cjs/components/FormElements/useFormikError.d.ts +18 -0
- package/dist/cjs/components/FormElements/useFormikError.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/FormElements/CustomTags/CustomTags.d.ts +28 -0
- package/dist/esm/components/FormElements/CustomTags/CustomTags.d.ts.map +1 -1
- package/dist/esm/components/FormElements/CustomTags/CustomTagsField.d.ts +15 -0
- package/dist/esm/components/FormElements/CustomTags/CustomTagsField.d.ts.map +1 -1
- package/dist/esm/components/FormElements/index.d.ts +1 -1
- package/dist/esm/components/FormElements/index.d.ts.map +1 -1
- package/dist/esm/components/FormElements/useFormikError.d.ts +18 -0
- package/dist/esm/components/FormElements/useFormikError.d.ts.map +1 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/FormElements/CustomTags/CustomTags.module.scss +6 -0
- package/src/components/FormElements/CustomTags/CustomTags.spec.tsx +203 -1
- package/src/components/FormElements/CustomTags/CustomTags.stories.tsx +43 -1
- package/src/components/FormElements/CustomTags/CustomTags.tsx +104 -15
- package/src/components/FormElements/CustomTags/CustomTagsField.spec.tsx +64 -0
- package/src/components/FormElements/CustomTags/CustomTagsField.tsx +40 -3
- package/src/components/FormElements/index.ts +5 -1
- package/src/components/FormElements/useFormikError.spec.tsx +70 -0
- package/src/components/FormElements/useFormikError.tsx +38 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { StringSchema } from 'yup';
|
|
2
3
|
import type { BaseFormControl, BaseInputEvents } from '../Form.models';
|
|
3
4
|
export interface CustomTagsProps extends BaseFormControl, BaseInputEvents {
|
|
4
5
|
/** Input element type (default: 'text')*/
|
|
@@ -15,6 +16,33 @@ export interface CustomTagsProps extends BaseFormControl, BaseInputEvents {
|
|
|
15
16
|
liveSuggestionsDelay?: number;
|
|
16
17
|
/** If set, enables live suggestions. Emits the currently typed input value and expects an array of suggestions to be displayed */
|
|
17
18
|
liveSuggestionsResolver?: (value: string) => Promise<string[]> | string[];
|
|
19
|
+
/**
|
|
20
|
+
* Optional Yup validation schema for validating new tags.
|
|
21
|
+
* A tag that fails validation is not added: it stays in the input and the
|
|
22
|
+
* validation message is shown, so the user can correct it.
|
|
23
|
+
*
|
|
24
|
+
* The schema is validated synchronously, so it must not contain async tests.
|
|
25
|
+
* Tests can read the tags that are already added from the validation context
|
|
26
|
+
* (see `CustomTagsValidationContext`).
|
|
27
|
+
* @example
|
|
28
|
+
* itemValidationSchema={Yup.string().url('Must be a valid URL')}
|
|
29
|
+
*/
|
|
30
|
+
itemValidationSchema?: StringSchema;
|
|
31
|
+
/** Tags that should be highlighted as invalid, e.g. existing values that fail validation */
|
|
32
|
+
invalidTags?: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The context `CustomTags` passes when validating a new tag with the
|
|
36
|
+
* `itemValidationSchema`. Tests can read it from `this.options.context`.
|
|
37
|
+
* @example
|
|
38
|
+
* Yup.string().test('unique-domain', 'Domain already added', function (value) {
|
|
39
|
+
* const { currentTags } = this.options.context as CustomTagsValidationContext;
|
|
40
|
+
* return !currentTags.some((tag) => getDomain(tag) === getDomain(value));
|
|
41
|
+
* });
|
|
42
|
+
*/
|
|
43
|
+
export interface CustomTagsValidationContext {
|
|
44
|
+
/** The tags that are already added */
|
|
45
|
+
currentTags: string[];
|
|
18
46
|
}
|
|
19
47
|
/**
|
|
20
48
|
* Form control that allows custom tags to be entered
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomTags.d.ts","sourceRoot":"","sources":["../../../../../src/components/FormElements/CustomTags/CustomTags.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"CustomTags.d.ts","sourceRoot":"","sources":["../../../../../src/components/FormElements/CustomTags/CustomTags.tsx"],"names":[],"mappings":"AACA,OAAO,KAON,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAKxC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAcvE,MAAM,WAAW,eAAgB,SAAQ,eAAe,EAAE,eAAe;IACvE,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0GAA0G;IAC1G,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kIAAkI;IAClI,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;IAC1E;;;;;;;;;;OAUG;IACH,oBAAoB,CAAC,EAAE,YAAY,CAAC;IACpC,4FAA4F;IAC5F,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,2BAA2B;IAC1C,sCAAsC;IACtC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAoCD;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA6WhD,CAAC"}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type CustomTagsProps } from './CustomTags';
|
|
3
|
+
/**
|
|
4
|
+
* This component should be used to render a CustomTags control inside a Formik form.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <Field name="tags" label="Tags" as={CustomTagsField} />
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Reject tags that fail validation before they are added
|
|
11
|
+
* <Field
|
|
12
|
+
* name="redirectUrls"
|
|
13
|
+
* label="Redirect URLs"
|
|
14
|
+
* as={CustomTagsField}
|
|
15
|
+
* itemValidationSchema={redirectUrlSchema}
|
|
16
|
+
* />
|
|
17
|
+
*/
|
|
3
18
|
export declare const CustomTagsField: React.FC<Omit<CustomTagsProps, 'error' | 'onChange'>>;
|
|
4
19
|
//# sourceMappingURL=CustomTagsField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomTagsField.d.ts","sourceRoot":"","sources":["../../../../../src/components/FormElements/CustomTags/CustomTagsField.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"CustomTagsField.d.ts","sourceRoot":"","sources":["../../../../../src/components/FormElements/CustomTags/CustomTagsField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAgBhE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CACpC,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,UAAU,CAAC,CAqB5C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { BooleanViewField, type BooleanViewFieldProps, } from './BooleanView/BooleanViewField';
|
|
2
2
|
export { Checkbox, type CheckboxProps } from './Checkbox/Checkbox';
|
|
3
3
|
export { CheckboxField } from './Checkbox/CheckboxField';
|
|
4
|
-
export { CustomTags, type CustomTagsProps } from './CustomTags/CustomTags';
|
|
4
|
+
export { CustomTags, type CustomTagsProps, type CustomTagsValidationContext, } from './CustomTags/CustomTags';
|
|
5
5
|
export { CustomTagsField } from './CustomTags/CustomTagsField';
|
|
6
6
|
export { DateTimeText, type DateTimeTextProps, } from './DateTimeField/DateTimeText';
|
|
7
7
|
export { DateTimeTextField } from './DateTimeField/DateTimeTextField';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/FormElements/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/FormElements/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,2BAA2B,GACjC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,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,cAAc,EACd,KAAK,mBAAmB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC3E,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,GAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,2 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the first error message contained in a Formik error value.
|
|
3
|
+
*
|
|
4
|
+
* Formik stores errors in the same shape as the values. For array fields
|
|
5
|
+
* validated with e.g. `Yup.array().of(...)`, the error is an array with one
|
|
6
|
+
* entry per item (`[undefined, 'Invalid URL']`), or an object for nested
|
|
7
|
+
* values. Form controls can only display a single message, so this picks the
|
|
8
|
+
* first one.
|
|
9
|
+
*
|
|
10
|
+
* @param error the raw error value Formik holds for a field
|
|
11
|
+
* @returns the first error message, or `undefined` if there is none
|
|
12
|
+
*/
|
|
13
|
+
export declare const getFirstErrorMessage: (error: unknown) => string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the error message Formik holds for the field with the given name.
|
|
16
|
+
* If the field holds multiple errors (e.g. one per array item), the first
|
|
17
|
+
* message is returned.
|
|
18
|
+
*/
|
|
1
19
|
export declare const useFormikError: (name: string) => string | undefined;
|
|
2
20
|
//# sourceMappingURL=useFormikError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormikError.d.ts","sourceRoot":"","sources":["../../../../src/components/FormElements/useFormikError.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFormikError.d.ts","sourceRoot":"","sources":["../../../../src/components/FormElements/useFormikError.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,MAAM,GAAG,SAmB9D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,SAGtD,CAAC"}
|