0.22.20 • Published 7 days ago

@synerise/ds-condition v0.22.20

Weekly downloads
144
License
ISC
Repository
github
Last release
7 days ago

id: condition

title: Condition

Condition UI Component

Installation

npm i @synerise/ds-condition
or
yarn add @synerise/ds-condition

Usage

import Condition from '@synerise/ds-condition'

<Condition
    texts={{
      stepNamePlaceholder: 'Step name',
      removeConditionRowTooltip: 'Remove',
      addConditionRowButton: 'and where',
    }}
    addCondition={() => {}}
    removeCondition={(stepId, conditionId) => {}}
    updateStepName={(stepId, name) => {}}
    minConditionsLength={1}
    maxConditionsLength={1}
    onChangeContext={(stepId, contextItem) => {}}
    onChangeSubject={(stepId, subjectItem) => {}}
    onChangeParameter={(stepId, conditionId, value) => {}}
    onChangeOperator={(stepId, conditionId, operator) => {}}
    onChangeFactorValue={(stepId, conditionId, factorValue) => {}
    onChangeFactorType={(stepId, conditionId, factorType) => {}
    steps={
      [{
        id: 1,
        stepName: 'Step #1',
        subject: {
          type: 'event',
          placeholder: 'Choose event',
          showPreview: false,
          iconPlaceholder: <NotificationsM />,
          selectedItem: undefined,
          items: SUBJECT_ITEMS,
          texts: SUBJECT_TEXTS,
        },
        context: {
          texts: CONTEXT_TEXTS,
          selectedItem: step.subject.selectedItem,
          items: CONTEXT_ITEMS,
          groups: CONTEXT_GROUPS,
        }
        conditions: [{
          id: 0,
          parameter: {
            availableFactorTypes: ['parameter'],
            selectedFactorType: 'parameter',
            defaultFactorType: 'parameter',
            setSelectedFactorType: () => {},
            value: undefined,
            parameters: {
              buttonLabel: 'Parameter',
              buttonIcon: <VarTypeStringM />,
              groups: PARAMETER_GROUPS,
              items: PARAMETER_ITEMS
            },
            withoutTypeSelector: true,
            texts: FACTORS_TEXTS,
          },
          operator: {
            value: value,
            items: OPERATORS_ITEMS,
            groups: OPERATORS_GROUPS,
            texts: OPERATORS_TEXTS,
          },
          factor: {
            selectedFactorType: 'text',
            defaultFactorType: 'text',
            textType: 'default',
            value: condition.factor.value,
            formulaEditor: <div>Formula editor</div>,
            parameters: {
              buttonLabel: 'Parameter',
              buttonIcon: <VarTypeStringM />,
              groups: PARAMETER_GROUPS,
              items: PARAMETER_ITEMS
            },
            texts: FACTORS_TEXTS,
          },
        }))
      }))
    } />

Demo

API

PropertyDescriptionTypeDefault
addConditionCallback called when user adds new row of conditions(stepId: React.ReactText) => void-
removeConditionCallback called when user clicks on remove row of condtions(stepId: React.ReactText, conditionRowId: React.ReactText) => void-
stepsArray contains all steps of conditionConditionStep[]-
textsTranslations objectTexts-
updateStepNameCallback called when user change the name of step(stepId: React.ReactText, value: string) => void-
addStepCallback called when user clicks on add step button() => void-
duplicateStepCallback called when user clicks on duplicate step button(stepId: React.ReactText) => void-
removeStepCallback called when user clicks on remove step button(stepId: React.ReactText) => void-
onChangeOrderCallback called when user change order of steps(order: ConditionStep[]) => void-
autoClearConditionAutomatically fires clearing values of dependent elementsBooleanfalse
minConditionsLengthMinimal length of conditions in stepnumber-
maxConditionsLengthMaximal length of conditions in stepnumber \ undefined-
onChangeContextCallback called when user change value of step context(stepId: React.ReactText, value: ContextItem \ ContextGroup \ undefined) => void-
onChangeSubjectCallback called when user change value of step subject(stepId: React.ReactText, value: SubjectItem \ undefined) => void-
onChangeParameterCallback called when user change value of condition parameter(stepId: React.ReactText, conditionId: React.ReactText, value: ParameterValue)-
onChangeOperatorCallback called when user change value of condition operator(stepId: React.ReactText, conditionId: React.ReactText, value: OperatorsItem \ undefined) => void-
onChangeFactorValueCallback called when user change value of condition factor(stepId: React.ReactText, conditionId: React.ReactText, value: OperatorsType \ undefined) => void-
onChangeFactorTypeCallback called when user change type of condition factor(stepId: React.ReactText, conditionId: React.ReactText, value: FactorType \ undefined) => void-
onUpdateStepNameCallback called when user change the name of step condition(stepId: React.ReactText, value: string) => void-
onDeactivateCallback called when user blur on of the condition inputs(stepId: React.ReactText, conditionId: string) => void-
getPopupContainerOverridePopup container function for child tooltips and dropdowns(trigger: HTMLElementnull) => HTMLElement;-
defaultOpenedComponentComponent which should be opened after render'subject' \ 'operator' \ 'factor' \ 'parameter' \ 'context'-
inputPropsgroup of props from ds-factors typesInputProps-

ConditionStep

PropertyDescriptionTypeDefault
conditionsRows of conditionsStepConditions[]-
idId of condition stepReact.ReactText-
stepNameThe name of stepstring-
subjectSubject optionsSubjectProps-
contextContextSelector optionsContextSelectorProps-
getPopupContainerOverridePopup container function for child tooltips and dropdowns(trigger: HTMLElementnull) => HTMLElement;-

StepConditions

PropertyDescriptionTypeDefault
factor?Factors selector optionsFactorsProps-
idId condition rowReact.ReactText-
operator?Operators selector optionsOperatorsProps-
parameter?Parameter selector optionsFactorsProps-

Selectors appereance rules

  • Parameter appers when parameter prop is provided
  • Operator appears without Parameter when operator prop is provided and parameter prop is not provided
  • Operator with Parameter appers when operator and parameter pros are provided and parameter.value is set
  • Factor appears only when operator prop and operator.value are provided

See Condition.spec.tsx for code examples

Texts

PropertyDescriptionTypeDefault
addConditionRowButtonLabel of add conditions row buttonstring-
removeConditionRowTooltipTooltip on remove conditions row buttonstring-
stepNamePlaceholderPlaceholder of step namestring-
addStepLabel of add step buttonstring-
duplicateTooltipTooltip on duplicate step buttonstring-
moveTooltipTooltip on move step buttonstring-
removeTooltipTooltip on remove step buttonstring-
dropLabelLabel on drop zonestring-
0.22.20

7 days ago

0.22.19

9 days ago

0.22.18

9 days ago

0.22.17

18 days ago

0.22.16

21 days ago

0.22.15

21 days ago

0.22.14

22 days ago

0.22.13

25 days ago

0.22.12

1 month ago

0.22.11

1 month ago

0.22.10

1 month ago

0.22.9

1 month ago

0.22.8

1 month ago

0.22.7

1 month ago

0.22.6

2 months ago

0.22.5

2 months ago

0.22.4

2 months ago

0.22.3

2 months ago

0.22.2

2 months ago

0.22.1

2 months ago

0.22.0

2 months ago

0.21.11

2 months ago

0.21.10

3 months ago

0.21.9

3 months ago

0.21.8

3 months ago

0.21.7

3 months ago

0.21.6

3 months ago

0.21.5

3 months ago

0.21.4

4 months ago

0.21.3

4 months ago

0.21.2

4 months ago

0.21.1

4 months ago

0.21.0

5 months ago

0.20.65

5 months ago

0.20.64

5 months ago

0.20.63

5 months ago

0.20.62

6 months ago

0.20.60

7 months ago

0.20.61

6 months ago

0.20.59

7 months ago

0.20.57

7 months ago

0.20.58

7 months ago

0.20.55

7 months ago

0.20.56

7 months ago

0.20.53

8 months ago

0.20.54

8 months ago

0.20.51

8 months ago

0.20.52

8 months ago

0.20.50

8 months ago

0.20.48

8 months ago

0.20.49

8 months ago

0.20.46

9 months ago

0.20.47

8 months ago

0.20.44

9 months ago

0.20.45

9 months ago

0.20.42

9 months ago

0.20.43

9 months ago

0.20.40

10 months ago

0.20.41

10 months ago

0.20.39

10 months ago

0.20.37

10 months ago

0.20.38

10 months ago

0.20.35

10 months ago

0.20.36

10 months ago

0.20.33

10 months ago

0.20.34

10 months ago

0.20.32

10 months ago

0.20.30

11 months ago

0.20.28

11 months ago

0.20.29

11 months ago

0.20.27

11 months ago

0.20.26

12 months ago

0.20.24

12 months ago

0.20.25

12 months ago

0.20.22

12 months ago

0.20.23

12 months ago

0.20.21

1 year ago

0.20.9

1 year ago

0.20.8

1 year ago

0.20.7

1 year ago

0.20.6

1 year ago

0.20.5

1 year ago

0.20.4

1 year ago

0.20.3

1 year ago

0.20.2

1 year ago

0.20.20

1 year ago

0.20.19

1 year ago

0.20.17

1 year ago

0.20.18

1 year ago

0.20.16

1 year ago

0.20.13

1 year ago

0.20.14

1 year ago

0.20.11

1 year ago

0.20.12

1 year ago

0.20.10

1 year ago

0.20.1

1 year ago

0.20.0

1 year ago

0.19.15

1 year ago

0.19.16

1 year ago

0.19.13

1 year ago

0.19.12

1 year ago

0.19.9

1 year ago

0.19.11

1 year ago

0.19.10

1 year ago

0.19.8

1 year ago

0.19.6

1 year ago

0.19.7

1 year ago

0.18.11

1 year ago

0.18.10

1 year ago

0.19.0

1 year ago

0.19.1

1 year ago

0.19.2

1 year ago

0.19.3

1 year ago

0.19.4

1 year ago

0.18.9

1 year ago

0.18.1

2 years ago

0.18.2

2 years ago

0.18.3

2 years ago

0.18.4

2 years ago

0.18.5

2 years ago

0.18.6

2 years ago

0.18.7

2 years ago

0.18.8

1 year ago

0.17.20

2 years ago

0.17.23

2 years ago

0.17.25

2 years ago

0.17.24

2 years ago

0.17.26

2 years ago

0.17.29

2 years ago

0.17.28

2 years ago

0.18.0

2 years ago

0.17.32

2 years ago

0.17.31

2 years ago

0.17.34

2 years ago

0.17.33

2 years ago

0.17.36

2 years ago

0.17.35

2 years ago

0.17.38

2 years ago

0.17.37

2 years ago

0.17.30

2 years ago

0.17.39

2 years ago

0.17.6

2 years ago

0.17.7

2 years ago

0.17.8

2 years ago

0.17.9

2 years ago

0.17.10

2 years ago

0.17.12

2 years ago

0.17.11

2 years ago

0.17.14

2 years ago

0.17.13

2 years ago

0.17.18

2 years ago

0.17.17

2 years ago

0.17.19

2 years ago

0.17.2

2 years ago

0.17.3

2 years ago

0.17.4

2 years ago

0.17.5

2 years ago

0.17.0

2 years ago

0.17.1

2 years ago

0.16.0

2 years ago

0.14.0

2 years ago

0.14.3

2 years ago

0.15.0

2 years ago

0.15.1

2 years ago

0.13.9

2 years ago

0.13.10

2 years ago

0.13.6

2 years ago

0.13.7

2 years ago

0.13.8

2 years ago

0.13.5

2 years ago

0.13.0

2 years ago

0.13.1

2 years ago

0.13.2

2 years ago

0.13.3

2 years ago

0.13.4

2 years ago

0.12.10

2 years ago

0.12.9

2 years ago

0.12.7

2 years ago

0.12.8

2 years ago

0.12.0

3 years ago

0.12.1

3 years ago

0.12.2

3 years ago

0.12.3

2 years ago

0.12.4

2 years ago

0.12.5

2 years ago

0.12.6

2 years ago

0.11.0

3 years ago

0.11.1

3 years ago

0.10.2

3 years ago

0.10.1

3 years ago

0.10.0

3 years ago

0.9.1

3 years ago

0.9.0

3 years ago

0.8.13

3 years ago

0.8.12

3 years ago

0.8.11

3 years ago

0.8.9

3 years ago

0.8.10

3 years ago

0.8.8

3 years ago

0.8.7

3 years ago

0.8.6

3 years ago

0.8.5

3 years ago

0.8.4

3 years ago

0.8.3

3 years ago

0.8.1

3 years ago

0.8.2

3 years ago

0.8.0

3 years ago

0.7.26

3 years ago

0.7.25

3 years ago

0.7.24

3 years ago

0.7.22

3 years ago

0.7.23

3 years ago

0.7.21

3 years ago

0.7.20

3 years ago

0.7.19

3 years ago

0.7.18

3 years ago

0.7.17

3 years ago

0.7.16

3 years ago

0.7.15

3 years ago

0.7.13

3 years ago

0.7.14

3 years ago

0.7.12

3 years ago

0.7.11

3 years ago

0.7.8

3 years ago

0.7.7

3 years ago

0.7.6

3 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.3

3 years ago

0.7.0

3 years ago

0.6.21

3 years ago

0.6.20

3 years ago

0.6.19

3 years ago

0.6.18

3 years ago

0.6.17

3 years ago

0.6.16

3 years ago

0.6.15

3 years ago

0.6.14

3 years ago

0.6.10

3 years ago

0.6.12

3 years ago

0.6.11

3 years ago

0.6.13

3 years ago

0.6.9

3 years ago

0.6.8

3 years ago

0.6.7

3 years ago

0.6.6

3 years ago

0.6.5

3 years ago

0.6.3

3 years ago

0.6.4

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.5.2

3 years ago

0.6.0

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.13

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.3

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.33

3 years ago

0.1.32

3 years ago

0.1.31

3 years ago

0.1.30

3 years ago

0.1.29

4 years ago

0.1.27

4 years ago

0.1.28

4 years ago

0.1.26

4 years ago

0.1.25

4 years ago

0.1.24

4 years ago

0.1.23

4 years ago

0.1.21

4 years ago

0.1.22

4 years ago

0.1.19

4 years ago

0.1.18

4 years ago

0.1.15

4 years ago

0.1.16

4 years ago

0.1.17

4 years ago

0.1.14

4 years ago

0.1.13

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.1

4 years ago