3.0.4 • Published 3 months ago

@arteneo/forge v3.0.4

Weekly downloads
119
License
MIT
Repository
github
Last release
3 months ago

Future plans

Read more in Unfinished components

Development

  1. Install dependencies using npm install.
  2. Build package using npm run build.
  3. Update version in package.json.
  4. Commit and push changes.
  5. Publish package using npm publish.

Branches

You can use following branches:

  1. main (default) - branch for current version 3.x
  2. v2 - branch for version 2.x
  3. v1 - branch for version 1.x

Table functionality

Toolbar

Batch actions

You can enable batch select (selectable rows via checkboxes in the table) by passing enableBatchSelect: true to <Table /> component.

There are following components available:

  • BatchAlertConfirm: Uses DialogBatchAlertConfirm which shows an Alert and uses DialogBatchButtonEndpoint (single endpoint)
  • BatchAlertConfirmMulti: Uses DialogBatchAlertConfirmMulti which shows an Alert and uses DialogBatchButtonMultiEndpoint (multiple endpoints one by one)
  • BatchConfirm: Uses DialogBatchConfirm which needs children and uses DialogBatchButtonEndpoint (single endpoint)
  • BatchConfirmMulti: Uses DialogBatchConfirmMulti which needs children and uses DialogBatchButtonMultiEndpoint (multiple endpoints one by one)
  • BatchForm: Uses DialogBatchFormFieldset which needs fields (single endpoint)
  • BatchFormAlert: Uses DialogBatchFormAlertFieldset which shows an Alert and needs fields (single endpoint)
  • BatchFormMulti: Uses DialogBatchFormMultiFieldset which needs fields (multiple endpoints based on form values)
  • BatchFormMultiAlert: Uses DialogBatchFormMultiAlertFieldset which shows an Alert and needs fields (multiple endpoints based on form values)

Example BatchAlertConfirm usage.

import React from "react";
import { Optional, BatchAlertConfirm, BatchAlertConfirmProps } from "@arteneo/forge";

type BatchDisableProps = Optional<BatchAlertConfirmProps, "dialogProps">;

const BatchDisable = (props: BatchDisableProps) => {
    return (
        <BatchAlertConfirm
            {...{
                label: "batch.device.disable.action",
                ...props,
                dialogProps: {
                    label: "batch.device.disable.label",
                    ...props.dialogProps,
                    confirmProps: {
                        endpoint: "/device/batch/disable",
                        ...props.dialogProps?.confirmProps,
                    },
                },
            }}
        />
    );
};

export default BatchDisable;
export { BatchDisableProps };

Example BatchAlertConfirmMulti usage.

import React from "react";
import { Optional, BatchAlertConfirmMulti, BatchAlertConfirmMultiProps } from "@arteneo/forge";

type BatchEnableProps = Optional<BatchAlertConfirmMultiProps, "dialogProps">;

const BatchEnable = (props: BatchEnableProps) => {
    return (
        <BatchAlertConfirmMulti
            {...{
                label: "batch.device.enable.action",
                ...props,
                dialogProps: {
                    label: "batch.device.enable.label",
                    ...props.dialogProps,
                    confirmProps: {
                        endpoint: (result) => "/device/" + result.id + "/enable",
                        resultDenyKey: "enable",
                        ...props.dialogProps?.confirmProps,
                    },
                },
            }}
        />
    );
};

export default BatchEnable;
export { BatchEnableProps };

Example BatchFormAlert usage.

import React from "react";
import { Optional, BatchFormAlert, BatchFormAlertProps, Text } from "@arteneo/forge";

type BatchVariableAddProps = Optional<BatchFormAlertProps, "dialogProps">;

const BatchVariableAdd = (props: BatchVariableAddProps) => {
    return (
        <BatchFormAlert
            {...{
                label: "batch.device.variableAdd.action",
                ...props,
                dialogProps: {
                    title: "batch.device.variableAdd.title",
                    label: "batch.device.variableAdd.label",
                    formProps: {
                        fields: {
                            name: <Text {...{ required: true }} />,
                        },
                        endpoint: "/device/batch/variable/add",
                    },
                    ...props.dialogProps,
                },
            }}
        />
    );
};

export default BatchVariableAdd;
export { BatchVariableAddProps };

Example BatchFormMultiAlert usage.

import React from "react";
import { Optional, BatchFormMultiAlert, BatchFormMultiAlertProps, Text } from "@arteneo/forge";

type BatchTemplateApplyProps = Optional<BatchFormMultiAlertProps, "dialogProps">;

const BatchTemplateApply = (props: BatchTemplateApplyProps) => {
    return (
        <BatchFormMultiAlert
            {...{
                label: "batch.device.templateApply.action",
                ...props,
                dialogProps: {
                    title: "batch.device.templateApply.title",
                    label: "batch.device.templateApply.label",
                    formProps: {
                        resultDenyKey: "templateApply",
                        fields: {
                            name: <Text {...{ required: true }} />,
                        },
                        endpoint: (result) => "/device/" + result.id + "/template/apply",
                    },
                    ...props.dialogProps,
                },
            }}
        />
    );
};

export default BatchTemplateApply;
export { BatchTemplateApplyProps };

Dialogs component overview

DialogProvider -> Utility context with initialization. Presenting children inside of a Dialog

Dialog -> Basic Dialog content setup: Title, Content, Actions DialogTitle -> Presentation component. Needs title (can be resolved using payload) DialogContent -> Presentation component. Shows loader when initializing otherwise children. Needs children (can be resolved using payload) DialogContentLoader -> Presentation component. Presents loader DialogActions -> Presentation component. Shows close button on the left and any passed actions buttons on the right (optionally resolved using payload)

DialogAlert -> Extends Dialog. Presents Alert (needs label which can be optionally resolved using payload) DialogAlertConfirm -> Adds DialogButtonEndpoint in actions to DialogAlert DialogConfirm -> Dialog with action button endpoint action (needs children)

DialogBatch -> Basic DialogBatch content setup: Title, DialogBatchContent, Actions DialogBatchContent -> Presentation component. Shows loader when initializing otherwise children and below DialogBatchProgress and DialogBatchResults. Needs children (can be resolved using payload) DialogBatchProgress -> Presentation component. Shows linear progress based on processed number of batchResults. DialogBatchResults -> Presentation component. Shows batchResults with status as rows.

DialogBatchAlert -> Extends DialogBatch. Presents Alert (needs label which can be optionally resolved using payload) DialogBatchConfirm -> DialogBatch with action DialogBatchButtonEndpoint action (needs children) DialogBatchAlertConfirm -> Adds DialogBatchButtonEndpoint in actions to DialogBatchAlert DialogBatchConfirmMulti -> DialogBatch with action DialogButtonMultiEndpoint action (needs children) DialogBatchAlertConfirmMulti -> Adds DialogButtonMultiEndpoint in actions to DialogBatchAlert

DialogButtonClose -> Overrides default onClick and adds onClose as parameter DialogButtonSubmit -> Adds default type: "submit" and loading and disabled states DialogButtonEndpoint -> Adjusts ButtonEndpoint (single endpoint) to Dialog by incorporating onClose to onSuccess and onCatch. Adds disable while initializing DialogBatchButtonMultiEndpoint -> Adjusts ButtonMultiEndpoint (multiple endpoints one by one) to DialogBatch by managing processing, finished and batchResults states through onStart, onFinish, onSuccess and onCatch. Adds disable while initializing or not finished. DialogBatchButtonEndpoint -> Adjusts DialogButtonEndpoint (single endpoint) to DialogBatch. It assumes that endpoint will return multiple batchResults in response.

DialogBatchForm -> Basic batch form in dialog component (sends endpoint and assumes that it will return multiple batchResults in response). Adds DialogButtonSubmit. (needs children which should include fields) DialogBatchFormFieldset -> Extends DialogBatchForm. Presents fields in a specific way. (does not need children) DialogBatchFormAlertFieldset -> Extends DialogBatchForm. Presents alert and fields in a specific way. (does not need children)

DialogBatchFormMulti -> Basic batch form multi in dialog component (multiple endpoints based on form values). Adds DialogButtonSubmit. (needs children which should include fields) DialogBatchFormMultiFieldset -> Extends DialogBatchFormMulti. Presents fields in a specific way. (does not need children) DialogBatchFormMultiAlertFieldset -> Extends DialogBatchFormMulti. Presents alert and fields in a specific way. (does not need children)

DialogForm -> Basic form in dialog component. Adds DialogButtonSubmit. (needs children which should include fields) DialogFormFieldset -> Extends DialogForm. Presents fields in a specific way. (does not need children)

3.0.4

3 months ago

3.0.3

10 months ago

3.0.2

10 months ago

3.0.1

11 months ago

3.0.0-alpha1

12 months ago

3.0.0-alpha2

12 months ago

3.0.0

12 months ago

2.2.3

1 year ago

2.2.2

1 year ago

2.0.1-test

1 year ago

2.0.1-test14

1 year ago

2.0.1-test11

1 year ago

2.0.1-test12

1 year ago

2.0.1-test10

1 year ago

0.8.0-alpha

1 year ago

2.2.1

1 year ago

2.0.1-test2

1 year ago

2.0.1-test3

1 year ago

2.0.1-test6

1 year ago

2.0.1-test7

1 year ago

2.0.1-test4

1 year ago

2.0.1-test5

1 year ago

2.0.1-test8

1 year ago

2.0.1-test9

1 year ago

2.0.0-test

1 year ago

2.1.9

1 year ago

2.1.12

1 year ago

2.1.10

1 year ago

2.1.11

1 year ago

2.1.8

1 year ago

2.1.7

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

0.9.3

1 year ago

0.9.2

1 year ago

0.9.1

1 year ago

2.0.15

2 years ago

2.0.16

2 years ago

2.0.14

2 years ago

2.1.0

1 year ago

2.0.19

2 years ago

2.0.17

2 years ago

2.0.18

2 years ago

2.0.24

1 year ago

2.0.22

1 year ago

2.0.23

1 year ago

2.0.20

2 years ago

2.0.21

2 years ago

2.0.13

2 years ago

2.0.12

2 years ago

2.0.1-alpha.28

2 years ago

2.0.1-alpha.29

2 years ago

2.0.1-alpha.26

2 years ago

2.0.1-alpha.27

2 years ago

2.0.1-alpha.24

2 years ago

2.0.1-alpha.25

2 years ago

2.0.1-alpha.22

2 years ago

2.0.1-alpha.23

2 years ago

2.0.1-alpha.20

2 years ago

2.0.1-alpha.21

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.1-alpha.19

2 years ago

2.0.1-alpha.17

2 years ago

2.0.1-alpha.18

2 years ago

2.0.1-alpha.16

2 years ago

0.9.0

2 years ago

2.0.11

2 years ago

2.0.10

2 years ago

2.0.1-alpha.37

2 years ago

2.0.1-alpha.35

2 years ago

2.0.1-alpha.36

2 years ago

2.0.1-alpha.33

2 years ago

2.0.1-alpha.34

2 years ago

2.0.1-alpha.31

2 years ago

2.0.1-alpha.32

2 years ago

2.0.1-alpha.30

2 years ago

2.0.1-alpha.15

2 years ago

2.0.1-alpha.13

2 years ago

2.0.1-alpha.14

2 years ago

2.0.1-alpha.11

2 years ago

2.0.1-alpha.12

2 years ago

2.0.1-alpha.10

2 years ago

2.0.1-alpha.7

2 years ago

2.0.1-alpha.8

2 years ago

2.0.1-alpha.9

2 years ago

2.0.0-alpha.18

2 years ago

2.0.0-alpha.17

2 years ago

2.0.0-alpha.16

2 years ago

2.0.0-alpha.15

2 years ago

2.0.1-alpha.6

2 years ago

2.0.1-alpha.1

2 years ago

2.0.1-alpha.2

2 years ago

2.0.1-alpha.3

2 years ago

2.0.1-alpha.4

2 years ago

2.0.1-alpha.5

2 years ago

2.0.0-alpha.7

2 years ago

2.0.0-alpha.8

2 years ago

2.0.0-alpha.11

2 years ago

2.0.0-alpha.3

2 years ago

2.0.0-alpha.10

2 years ago

2.0.0-alpha.4

2 years ago

2.0.0-alpha.5

2 years ago

2.0.0-alpha.6

2 years ago

2.0.0-alpha.0

2 years ago

2.0.0-alpha.1

2 years ago

2.0.0-alpha.2

2 years ago

2.0.0-alpha.14

2 years ago

2.0.0-alpha.13

2 years ago

2.0.0-alpha.12

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.10

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago