@shipengine/formik-giger 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/README.md +44 -0
  2. package/package.json +53 -0
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # `@packlink/formik-giger`
2
+
3
+ Bindings for using [Formik](https://github.com/formium/formik) with [Giger](https://github.com/packlink-dev/giger).
4
+
5
+ ## Usage
6
+
7
+ Check [stories](https://github.com/packlink-dev/giger/tree/master/packages/integrations/formik/src/stories) for examples on how to integrate this package in your application.
8
+
9
+ ### FormField
10
+
11
+ With Design team we think about a "global" solution for the spaces (margin / paddings) at the `Input` component ([Giger](https://ui-components.packlink.com/?path=/story/components-forms-input--input-type-text)) so thats why `FormField` component exists, this component accepts any children (Input, Select, etc) and a [message interface](https://github.com/packlink-dev/giger/blob/master/src/components/Form/FormField/FormField.tsx#L10) so we can forget to declare the Input + FieldMessage paddings across Packlink.
12
+
13
+ This component (FormField - Phavior) it's easy to use:
14
+
15
+ ```js
16
+ import { Field } from 'formik';
17
+ import { FormField, Input } from '@packlink/formik-giger';
18
+
19
+ <FormField name="username">
20
+ <Field component={Input} label="username" />
21
+ </FormField>;
22
+ ```
23
+
24
+ This way, (just like the other Input, TextArea ... components inside this package) Formik will handle the onChange, onBlur handlers among other things.
25
+ Plus: this will render the error message when there is an error, but you can also pass a custom message to render:
26
+
27
+ ```js
28
+ import { Field } from 'formik';
29
+ import { FieldMessageType } from '@shipengine/giger';
30
+ import { FormField, Input } from '@packlink/formik-giger';
31
+
32
+ <FormField
33
+ name="username"
34
+ message={{
35
+ type: FieldMessageType.INFO,
36
+ content: 'Use a valid username',
37
+ }}
38
+ >
39
+ <Field component={Input} label="username" />
40
+ </FormField>;
41
+ ```
42
+
43
+ Take in mind that **errors are top priority** that means that an error will always be rendered before any custom message you may pass.
44
+ When the error it's gone, the default message will render.
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@shipengine/formik-giger",
3
+ "version": "0.2.0",
4
+ "description": "A package providing formik bindings for Giger",
5
+ "homepage": "https://github.com/shipengine/giger",
6
+ "sideEffects": false,
7
+ "license": "ISC",
8
+ "main": "dist/lib/index.js",
9
+ "module": "dist/esm/index.js",
10
+ "types": "dist/lib/index.d.ts",
11
+ "typings": "dist/lib/index.d.ts",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "source": "src/index.ts",
16
+ "publishConfig": {
17
+ "access": "restricted"
18
+ },
19
+ "lint-staged": {
20
+ "**/*.ts?(x)": "yarn run lint"
21
+ },
22
+ "browserslist": [
23
+ "extends @packlink/browserslist-config"
24
+ ],
25
+ "scripts": {
26
+ "start": "packlink-scripts start --rollup",
27
+ "build": "packlink-scripts build --rollup",
28
+ "lint": "yarn type-check && packlink-scripts lint",
29
+ "lint:ci": "yarn type-check && packlink-scripts lint",
30
+ "type-check": "tsc --noEmit",
31
+ "test": "node --expose-gc ../../../node_modules/.bin/packlink-scripts test --maxWorkers=40% --logHeapUsage",
32
+ "test:ci": "node --expose-gc ../../../node_modules/.bin/packlink-scripts test --ci --runInBand --coverage --logHeapUsage",
33
+ "postpublish": "packlink-scripts metrics"
34
+ },
35
+ "devDependencies": {
36
+ "@shipengine/giger": "^0.2.0",
37
+ "formik": "^2.4.2",
38
+ "test-utils": "^2.7.0",
39
+ "yup": "0.32.11"
40
+ },
41
+ "dependencies": {
42
+ "@babel/runtime": "^7.21.0",
43
+ "@types/flat": "^5.0.2",
44
+ "flat": "^5.0.2"
45
+ },
46
+ "peerDependencies": {
47
+ "@emotion/react": "^11.10.6",
48
+ "@shipengine/giger": ">=0.1.0",
49
+ "formik": ">=2.2.9",
50
+ "react": "^16.14.0 || ^17.0.0 || ^18.0.0"
51
+ },
52
+ "gitHead": "11d8ba1d2a7c2c827319a33a0963175692abd5d2"
53
+ }