@registrucentras/rc-ses-react-components 1.6.5 → 1.6.6

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.
@@ -0,0 +1,134 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import { fn } from '@storybook/test'
3
+ import React, { useState } from 'react'
4
+ import { useForm } from 'react-hook-form'
5
+
6
+ import RcSesSearchInput from '@/components/form/inputs/SearchInput'
7
+ import SingleStepFormModel from '@/examples/SingleStepForm/types/SingleStepFormModel'
8
+
9
+ const meta: Meta<typeof RcSesSearchInput> = {
10
+ title: 'components/inputs/SearchInput',
11
+ component: RcSesSearchInput,
12
+ tags: ['autodocs'],
13
+ argTypes: {
14
+ label: {
15
+ control: 'text',
16
+ },
17
+ labelSubtitle: {
18
+ control: 'text',
19
+ },
20
+ required: {
21
+ control: 'boolean',
22
+ },
23
+ placeholder: {
24
+ control: 'text',
25
+ },
26
+ onlyNumbers: {
27
+ control: 'boolean',
28
+ },
29
+ sideLabel: {
30
+ control: 'boolean',
31
+ },
32
+ showSearchButton: {
33
+ control: 'boolean',
34
+ },
35
+ searchButtonLabel: {
36
+ control: 'text',
37
+ },
38
+ slotProps: {
39
+ control: 'object',
40
+ },
41
+ disabled: {
42
+ control: 'boolean',
43
+ },
44
+ },
45
+ }
46
+
47
+ export default meta
48
+
49
+ type Story = StoryObj<typeof RcSesSearchInput>
50
+
51
+ const StoryTemplate = (args: React.ComponentProps<typeof RcSesSearchInput>) => {
52
+ const { onSearch, slotProps, ...restArgs } = args
53
+ const [lastSearchValue, setLastSearchValue] = useState('')
54
+ const [searchCount, setSearchCount] = useState(0)
55
+ const {
56
+ control,
57
+ formState: { errors },
58
+ } = useForm<SingleStepFormModel>({
59
+ mode: 'all',
60
+ })
61
+
62
+ const handleSearch = (value: string) => {
63
+ const newCount = searchCount + 1
64
+ setLastSearchValue(value)
65
+ setSearchCount(newCount)
66
+ onSearch(value)
67
+ }
68
+
69
+ return (
70
+ <div>
71
+ <RcSesSearchInput
72
+ {...restArgs}
73
+ control={control}
74
+ id='searchable'
75
+ errors={errors?.searchable}
76
+ name='searchable'
77
+ onSearch={handleSearch}
78
+ slotProps={slotProps}
79
+ />
80
+ <p style={{ marginTop: 12 }}>
81
+ Searches: {searchCount} | Last value: {lastSearchValue || '-'}
82
+ </p>
83
+ </div>
84
+ )
85
+ }
86
+
87
+ export const Main: Story = {
88
+ args: {
89
+ label: 'Search Input Field',
90
+ placeholder: 'Type to search',
91
+ onSearch: fn(),
92
+ },
93
+ render: (args) => <StoryTemplate {...args} />,
94
+ }
95
+
96
+ export const OnlyRequired: Story = {
97
+ args: {
98
+ onSearch: fn(),
99
+ },
100
+ render: (args) => <StoryTemplate {...args} />,
101
+ }
102
+
103
+ export const WithoutButton: Story = {
104
+ args: {
105
+ ...Main.args,
106
+ showSearchButton: false,
107
+ },
108
+ render: (args) => <StoryTemplate {...args} />,
109
+ }
110
+
111
+ export const WithoutLabel: Story = {
112
+ args: {
113
+ ...Main.args,
114
+ label: undefined,
115
+ },
116
+ render: (args) => <StoryTemplate {...args} />,
117
+ }
118
+
119
+ export const SideLabel: Story = {
120
+ args: {
121
+ ...Main.args,
122
+ sideLabel: true,
123
+ },
124
+ render: (args) => <StoryTemplate {...args} />,
125
+ }
126
+
127
+ export const OnlyNumbers: Story = {
128
+ args: {
129
+ ...Main.args,
130
+ onlyNumbers: true,
131
+ placeholder: 'Only numbers allowed',
132
+ },
133
+ render: (args) => <StoryTemplate {...args} />,
134
+ }
@@ -0,0 +1,15 @@
1
+ import { Components } from '@mui/material'
2
+
3
+ const MuiOutlinedInput: Components['MuiOutlinedInput'] = {
4
+ styleOverrides: {
5
+ root: {
6
+ borderRadius: '.5rem',
7
+
8
+ '.MuiOutlinedInput-notchedOutline': {
9
+ borderRadius: '.5rem',
10
+ },
11
+ },
12
+ },
13
+ }
14
+
15
+ export default MuiOutlinedInput
@@ -26,6 +26,7 @@ import MuiFormLabel from '@/theme/light/MuiFormLabel'
26
26
  import MuiIconButton from '@/theme/light/MuiIconButton'
27
27
  import MuiInputBase from '@/theme/light/MuiInputBase'
28
28
  import MuiLinearProgress from '@/theme/light/MuiLinearProgress'
29
+ import MuiOutlinedInput from '@/theme/light/MuiOutlinedInput'
29
30
  import MuiPickersLayout from '@/theme/light/MuiPickersLayout'
30
31
  import MuiPopover from '@/theme/light/MuiPopover'
31
32
  import MuiRadio from '@/theme/light/MuiRadio'
@@ -108,6 +109,7 @@ const theme = createTheme(themePalette, ltLT, enUS, {
108
109
  MuiIconButton,
109
110
  MuiInputBase,
110
111
  MuiLinearProgress,
112
+ MuiOutlinedInput,
111
113
  MuiPickersLayout,
112
114
  MuiPagination,
113
115
  MuiPaginationItem,