@registrucentras/rc-ses-react-components 1.4.0 → 1.4.1

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.
Files changed (34) hide show
  1. package/dist/components/layout/ServiceFormContainer/{components → AccordionFormContainer/components}/AccordionCollapseControls.d.ts +1 -1
  2. package/dist/components/layout/ServiceFormContainer/{index.d.ts → AccordionFormContainer/index.d.ts} +1 -1
  3. package/dist/components/layout/ServiceFormContainer/AccordionFormContainer/utils.d.ts +4 -0
  4. package/dist/components/layout/ServiceFormContainer/CardFormContainer/index.d.ts +11 -0
  5. package/dist/components/layout/ServiceWizardStepper/components/DesktopStepper.d.ts +2 -1
  6. package/dist/components/layout/ServiceWizardStepper/index.d.ts +4 -2
  7. package/dist/library/index.d.ts +6 -2
  8. package/dist/library/types.d.ts +4 -0
  9. package/dist/registrucentras-rc-ses-react-components.cjs +10 -10
  10. package/dist/registrucentras-rc-ses-react-components.js +985 -922
  11. package/dist/stories/components/form/CardFormContainer.stories.d.ts +7 -0
  12. package/dist/stories/components/form/ServiceFormContainer.stories.d.ts +1 -1
  13. package/package.json +1 -1
  14. package/src/App.tsx +4 -0
  15. package/src/components/layout/ServiceFormContainer/{index.tsx → AccordionFormContainer/index.tsx} +1 -1
  16. package/src/components/layout/ServiceFormContainer/{utils.ts → AccordionFormContainer/utils.ts} +2 -2
  17. package/src/components/layout/ServiceFormContainer/CardFormContainer/index.test.tsx +78 -0
  18. package/src/components/layout/ServiceFormContainer/CardFormContainer/index.tsx +68 -0
  19. package/src/components/layout/ServiceWizardStepper/ServiceWizardStepper.css +19 -3
  20. package/src/components/layout/ServiceWizardStepper/StepConnector.tsx +1 -1
  21. package/src/components/layout/ServiceWizardStepper/components/DesktopStepper.tsx +17 -2
  22. package/src/components/layout/ServiceWizardStepper/components/StyledStepLabel.tsx +5 -1
  23. package/src/components/layout/ServiceWizardStepper/index.tsx +10 -3
  24. package/src/examples/CardMultipleStepForm/index.tsx +93 -0
  25. package/src/examples/MultipleStepForm/index.tsx +1 -1
  26. package/src/examples/SingleStepForm/index.tsx +1 -1
  27. package/src/library/index.ts +6 -1
  28. package/src/library/types.ts +5 -0
  29. package/src/main.tsx +5 -0
  30. package/src/stories/components/Accordion.stories.tsx +1 -1
  31. package/src/stories/components/form/CardFormContainer.stories.tsx +135 -0
  32. package/src/stories/components/form/ServiceFormContainer.stories.tsx +1 -1
  33. package/dist/components/layout/ServiceFormContainer/utils.d.ts +0 -4
  34. /package/src/components/layout/ServiceFormContainer/{components → AccordionFormContainer/components}/AccordionCollapseControls.tsx +0 -0
@@ -0,0 +1,135 @@
1
+ import { Button, Container, Typography } from '@mui/material'
2
+ import type { Meta, StoryFn } from '@storybook/react'
3
+ import { useState } from 'react'
4
+
5
+ import RcSesCardFormContainer from '@/components/layout/ServiceFormContainer/CardFormContainer'
6
+ import { StepItem } from '@/components/layout/ServiceWizardStepper/StepperTypes'
7
+ import FieldView from '@/components/storybook/FieldView'
8
+ import Fields from '@/components/storybook/Fields'
9
+
10
+ const shortSteps: StepItem[] = [
11
+ { id: '1', state: 'completed', title: 'Paslauga' },
12
+ { id: '2', state: 'active', title: 'Duomenys' },
13
+ { id: '3', state: 'pending', title: 'Patvirtinimas' },
14
+ ]
15
+
16
+ const longSteps: StepItem[] = [
17
+ { id: '1', state: 'completed', title: 'Paslauga' },
18
+ { id: '2', state: 'completed', title: 'Duomenys' },
19
+ { id: '3', state: 'active', title: 'Dokumentai' },
20
+ { id: '4', state: 'pending', title: 'Mokėjimas' },
21
+ { id: '5', state: 'pending', title: 'Patvirtinimas' },
22
+ ]
23
+
24
+ const meta: Meta<typeof RcSesCardFormContainer> = {
25
+ title: 'components/common/form/CardFormContainer',
26
+ component: RcSesCardFormContainer,
27
+ tags: ['autodocs'],
28
+ argTypes: {
29
+ steps: { table: { disable: true } },
30
+ onStepClick: { table: { disable: true } },
31
+ },
32
+ }
33
+
34
+ export default meta
35
+
36
+ const DemoContent = () => (
37
+ <>
38
+ <Typography variant='h6'>Pavadinimas</Typography>
39
+ <Typography variant='body2' sx={{ mb: 2 }}>
40
+ Papildomas aprašymo tekstas
41
+ </Typography>
42
+
43
+ <Container
44
+ sx={{
45
+ height: 140,
46
+ background: '#EDEDED',
47
+ borderRadius: '8px',
48
+ display: 'flex',
49
+ alignItems: 'center',
50
+ justifyContent: 'center',
51
+ mb: 2,
52
+ }}
53
+ >
54
+ <Typography variant='body2'>Vidinis paslaugų front-end sprendimas</Typography>
55
+ </Container>
56
+ </>
57
+ )
58
+
59
+ const createTemplate =
60
+ (
61
+ initialSteps: StepItem[],
62
+ forcedLayout?: 'row' | 'column',
63
+ ): StoryFn<typeof RcSesCardFormContainer> =>
64
+ (args) => {
65
+ const [currentSteps, setCurrentSteps] = useState(initialSteps)
66
+ const activeStep = currentSteps.findIndex((s) => s.state === 'active')
67
+
68
+ const handleBack = () => {
69
+ if (activeStep <= 0) return
70
+
71
+ const updated = currentSteps.map((step, index) => {
72
+ if (index < activeStep - 1) return { ...step, state: 'completed' as const }
73
+ if (index === activeStep - 1) return { ...step, state: 'active' as const }
74
+ return { ...step, state: 'pending' as const }
75
+ })
76
+
77
+ setCurrentSteps(updated)
78
+ }
79
+
80
+ const handleNext = () => {
81
+ if (activeStep === -1 || activeStep === currentSteps.length - 1) return
82
+
83
+ const updated = currentSteps.map((step, index) => {
84
+ if (index < activeStep + 1) return { ...step, state: 'completed' as const }
85
+ if (index === activeStep + 1) return { ...step, state: 'active' as const }
86
+ return { ...step, state: 'pending' as const }
87
+ })
88
+
89
+ setCurrentSteps(updated)
90
+ }
91
+
92
+ return (
93
+ <Fields>
94
+ <FieldView>
95
+ <RcSesCardFormContainer
96
+ {...args}
97
+ layout={forcedLayout}
98
+ steps={currentSteps}
99
+ onStepClick={setCurrentSteps}
100
+ leadingActions={
101
+ <Button onClick={handleBack} disabled={activeStep <= 0}>
102
+ Back
103
+ </Button>
104
+ }
105
+ trailingActions={
106
+ <>
107
+ <Button variant='outlined'>Button</Button>
108
+ <Button
109
+ variant='contained'
110
+ onClick={handleNext}
111
+ disabled={activeStep === currentSteps.length - 1}
112
+ >
113
+ Next
114
+ </Button>
115
+ </>
116
+ }
117
+ >
118
+ <DemoContent />
119
+ </RcSesCardFormContainer>
120
+ </FieldView>
121
+ </Fields>
122
+ )
123
+ }
124
+
125
+ export const HorizontalDemo = createTemplate(shortSteps, 'column')
126
+ HorizontalDemo.args = {
127
+ title: 'Antraštės tekstas',
128
+ description: 'Papildomas aprašymo tekstas',
129
+ }
130
+
131
+ export const VerticalDemo = createTemplate(longSteps, 'row')
132
+ VerticalDemo.args = {
133
+ title: 'Antraštės tekstas',
134
+ description: 'Papildomas aprašymo tekstas',
135
+ }
@@ -5,7 +5,7 @@ import { Meta, StoryContext, StoryFn } from '@storybook/react'
5
5
 
6
6
  import RcSesAccordion from '@/components/common/Accordion'
7
7
  import useAccordionController from '@/components/common/Accordion/hooks/useAccordionController'
8
- import RcSesServiceFormContainer from '@/components/layout/ServiceFormContainer'
8
+ import RcSesServiceFormContainer from '@/components/layout/ServiceFormContainer/AccordionFormContainer'
9
9
  import FieldView from '@/components/storybook/FieldView'
10
10
  import Fields from '@/components/storybook/Fields'
11
11
  import BasicInformationForm from '@/examples/MultipleStepForm/components/BasicInformationForm'
@@ -1,4 +0,0 @@
1
- import { AccordionControllerState } from '../../common/Accordion/types/AccordionControllerState';
2
- import { StepItem } from '../ServiceWizardStepper/StepperTypes';
3
- declare function mapAccordionStateToSteps(state: AccordionControllerState): StepItem[];
4
- export default mapAccordionStateToSteps;