0.6.1 • Published 2 months ago

@joyfill/components-react-native v0.6.1

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
2 months ago

joyfill_logo

@joyfill/components-react-native

We recommend visiting our official react-native setup guide https://docs.joyfill.io/docs/react-native.

Project Requirements

Note userAccessTokens & identifiers will need to be stored on your end (usually on a user and set of existing form field-based data) in order to interact with our API and UI Components effectively

  • React and React DOM v17+
  • React-Native v0.70.0+

Install Dependency

React-Native CLI (bare)

$ npm install @joyfill/components-react-native@latest react-native-webview react-native-svg @react-native-community/datetimepicker --save
$ cd ios && pod install
$ yarn add @joyfill/components-react-native@latest react-native-webview react-native-svg @react-native-community/datetimepicker
$ cd ios && pod install

Expo (managed)

$ npx expo install @joyfill/components-react-native@latest react-native-webview react-native-svg @react-native-community/datetimepicker

Implement your code

For full examples please see https://docs.joyfill.io/docs/react-native.

Below is a usable example of our react-native document native embedded. This will show a readonly or fillable depending on the mode form to your users. The document (form) shown is based on your documentId.

Make sure to replace the userAccessToken and documentId. Note that documentId is just for this example, you can call our List all documents endpoint and grab an ID from there.

import React, { useState, useEffect } from 'react';
import { Dimensions, View } from 'react-native';
import { joyfillRetrieve } from './api.js';
import { JoyDoc, getDefaultDocument } from '@joyfill/components-react-native';

const screenWidth = Dimensions.get('window').width;

const userAccessToken = '<REPLACE_ME>';
const documentId = '<REPLACE_ME>';

function Document() {

  const [doc, setDoc] = useState(getDefaultDocument());

  // retrieve the document from our api (you can also pass an initial documentId into JoyDoc)
  useEffect(() => {
    const response = await joyfillRetrieve(documentId, userAccessToken).then(doc => {
      setDoc(response);
    });
  }, []);

  return (
    <View style={{flex: 1}}>
      <JoyDoc
        mode="fill"
        doc={doc}
        width={screenWidth}
        onChange={(changelogs, doc) => {
          console.log('onChange doc: ', doc);
          setDoc(doc);
        }}
        onUploadAsync={async (params, fileUploads) => {
          // to see a full utilization of upload see api.js -> examples
          console.log('onUploadAsync: ', fileUploads);
        }}
      />
    </View>
  );
}

export default Document;

JoyDoc Params

  • mode: 'fill' | 'readonly'
    • Required*
    • Enables and disables certain JoyDoc functionality and features.
    • Options
      • fill is the mode where you simply input the field data into the form
      • readonly is the mode where everything in the form is set to read-only.
  • doc: object
    • The default JoyDoc JSON starting object to load into the component view. Must be in the JoyDoc JSON data structure.
  • initialPageId: string
    • Specify the initial page to display in the form.
    • Utilize the _id property of a Page object. For instance, page._id.
    • If page is not found within the doc it will fallback to displaying the first page in the pages array.
  • navigation: object
    • Display/hide page navigation.
    • Set the pages property to true (display) or false (hide). For instance, {pages: false} hides the page navigation.
  • onChange: (changelogs: object_array, doc: object) => {}
    • Used to listen to any changes to the style, layout, values, etc. across all modes.
    • changelogs: object_array
      • Can contain one ore more of the changelog object types supported.
    • doc: object
      • Fully updated JoyDoc JSON structure with changes applied.
  • theme: object
    • Specify custom theme properties.
    • Sample theme object { fontFamily: "Arial", button: { primary: { fontWeight: "bold", borderRadius: "10px", ... } }
    • The button primary, secondary, and danger support the React Native Supported Styles
    • fontFamily: String
      • Apply custom font family to display text.
      • IMPORTANT: If you're using a custom font, you are responsible to ensure the fonts are loaded before rendering the component. Could result in an error if font is not loaded properly before render.
    • button.primary: object
      • Specifies styles for primary field buttons.
    • button.secondary: object
      • Specifies styles for secondary internal field buttons.
    • button.danger: object:
      • Specifies styles for delete buttons.

Components Helper Methods

  • getDefaultDocument
    • Get a default Joyfill Document object
  • getDefaultTemplate
    • Get a default Joyfill Template object
  • getDocumentFromTemplate: ( template: object )
    • Generate a Joyfill Document object from a Joyfill Template object
  • duplicate: ( original: object, defaults: object )
    • Duplicate a Joyfill Document or Template object.
  • duplicatePage: ( original: object, fileId: string, pageId: string )
    • Duplicate a Joyfill Document or Template Page object.
    • Returns: { doc: object, changelogs: array }
      • doc fully updated Document or Template with the page added
      • changelogs array of changelogs for new duplicate page.
0.6.1-beta.16

2 months ago

0.6.1-beta.15

2 months ago

0.6.1-beta.17

2 months ago

0.6.1-beta.19

2 months ago

0.6.1-beta.10

2 months ago

0.6.1-beta.12

2 months ago

0.6.1-beta.11

2 months ago

0.6.1-beta.14

2 months ago

0.6.1-beta.13

2 months ago

0.6.1-beta.21

2 months ago

0.6.1-beta.20

2 months ago

0.6.1-beta.22

2 months ago

0.6.1-beta.1.1

2 months ago

0.6.1-beta.1.2

2 months ago

0.6.1

2 months ago

0.6.1-beta.8

2 months ago

0.6.1-beta.9

2 months ago

0.6.1-beta.1.0

2 months ago

0.6.1-beta.5

2 months ago

0.6.1-beta.6

2 months ago

0.6.1-beta.7

2 months ago

0.6.1-beta.4

2 months ago

0.6.1-beta.1

3 months ago

0.6.1-beta.2

3 months ago

0.6.1-beta.3

2 months ago

0.6.1-beta.0

3 months ago

0.6.0

4 months ago

0.6.0-beta.1

4 months ago

0.6.0-beta.0

5 months ago

0.5.0

6 months ago

0.5.0-beta.0

6 months ago

0.4.0

7 months ago

0.4.0-beta.2

7 months ago

0.4.0-beta.1

7 months ago

0.4.0-beta.0

7 months ago

0.3.1

9 months ago

0.3.0

9 months ago

0.2.0

9 months ago

0.1.33

9 months ago

0.1.32

9 months ago

0.1.31

9 months ago

0.1.29

9 months ago

0.1.28

9 months ago

0.1.27

9 months ago

0.1.26

9 months ago

0.1.25

9 months ago

0.1.24

9 months ago

0.1.23

9 months ago

0.1.22

9 months ago

0.1.21

9 months ago

0.1.20

9 months ago

0.1.19

9 months ago

0.1.18

9 months ago

0.1.17

9 months ago

0.1.15

9 months ago

0.1.14

9 months ago

0.1.13

9 months ago

0.1.12

9 months ago

0.1.11

9 months ago

0.1.10

9 months ago

0.1.9

9 months ago

0.1.8

9 months ago

0.1.7

9 months ago

0.1.6

9 months ago

0.1.5

9 months ago

0.1.4

9 months ago

0.1.3

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago