@licklist/design 0.72.72-dev.2 → 0.72.72-dev.4
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.
- package/dist/auth/Router.d.ts.map +1 -1
- package/dist/auth/Router.js +18 -14
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductsControl.js +2 -0
- package/dist/product-set/product/ProductControl.d.ts +2 -0
- package/dist/product-set/product/ProductControl.d.ts.map +1 -1
- package/dist/product-set/product/ProductControl.js +7 -0
- package/dist/product-set/product/scanRange/ProductScanRangeControl.d.ts +12 -0
- package/dist/product-set/product/scanRange/ProductScanRangeControl.d.ts.map +1 -0
- package/dist/product-set/product/scanRange/ProductScanRangeControl.js +153 -0
- package/dist/product-set/product/scanRange/index.d.ts +2 -0
- package/dist/product-set/product/scanRange/index.d.ts.map +1 -0
- package/dist/product-set/utils/index.d.ts +2 -0
- package/dist/product-set/utils/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/auth/Router.tsx +19 -19
- package/src/index.ts +0 -1
- package/src/product-set/form/ProductsControl.tsx +2 -0
- package/src/product-set/product/ProductControl.tsx +18 -12
- package/src/product-set/product/scanRange/ProductScanRangeControl.stories.ts +45 -0
- package/src/product-set/product/scanRange/ProductScanRangeControl.tsx +163 -0
- package/src/product-set/product/scanRange/index.ts +1 -0
- package/yarn.lock +153 -153
- package/dist/header/BookeditHeader.d.ts +0 -12
- package/dist/header/BookeditHeader.d.ts.map +0 -1
- package/dist/header/BookeditHeader.js +0 -21
- package/dist/header/Header.d.ts +0 -24
- package/dist/header/Header.d.ts.map +0 -1
- package/dist/header/Header.js +0 -81
- package/dist/header/elements/CompanySelector.d.ts +0 -11
- package/dist/header/elements/CompanySelector.d.ts.map +0 -1
- package/dist/header/elements/CompanySelector.js +0 -36
- package/dist/header/elements/index.d.ts +0 -3
- package/dist/header/elements/index.d.ts.map +0 -1
- package/dist/header/index.d.ts +0 -6
- package/dist/header/index.d.ts.map +0 -1
- package/src/header/BookeditHeader.tsx +0 -34
- package/src/header/Header.stories.tsx +0 -72
- package/src/header/Header.tsx +0 -107
- package/src/header/elements/CompanySelector.tsx +0 -47
- package/src/header/elements/Elements.stories.tsx +0 -33
- package/src/header/elements/index.ts +0 -3
- package/src/header/index.ts +0 -7
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import HookFormService from '@licklist/plugins/dist/services/Form/HookFormService'
|
|
2
|
+
import {
|
|
3
|
+
FieldNamePrefixPath,
|
|
4
|
+
FormValues,
|
|
5
|
+
} from '@licklist/plugins/dist/types/services/Form/hook-form-service'
|
|
6
|
+
import { useId } from '@react-aria/utils'
|
|
7
|
+
import { Form } from 'react-bootstrap'
|
|
8
|
+
import Col from 'react-bootstrap/Col'
|
|
9
|
+
import InputGroup from 'react-bootstrap/InputGroup'
|
|
10
|
+
import Row from 'react-bootstrap/Row'
|
|
11
|
+
import { Controller, Path, useFormContext } from 'react-hook-form'
|
|
12
|
+
import { useTranslation } from 'react-i18next'
|
|
13
|
+
|
|
14
|
+
import { ReactComponent as IncrementIcon } from '../../../assets/dashboard/increment.svg'
|
|
15
|
+
|
|
16
|
+
export interface ProductScanRangeControlValues extends FormValues {
|
|
17
|
+
scanRangeStart: number
|
|
18
|
+
scanRangeEnd: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ProductScanRangeControlProps<T> extends FieldNamePrefixPath<T> {
|
|
22
|
+
isLoading: boolean
|
|
23
|
+
onFocus?: (e: React.SyntheticEvent) => void
|
|
24
|
+
isOverrides?: boolean
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function ProductScanRangeControl<T extends FormValues>(
|
|
28
|
+
props: ProductScanRangeControlProps<T>,
|
|
29
|
+
) {
|
|
30
|
+
const { isLoading = false, fieldNamePrefix, onFocus, isOverrides } = props
|
|
31
|
+
const {
|
|
32
|
+
control,
|
|
33
|
+
formState: { errors },
|
|
34
|
+
setValue,
|
|
35
|
+
watch
|
|
36
|
+
} = useFormContext<T>()
|
|
37
|
+
const { t } = useTranslation('Design')
|
|
38
|
+
|
|
39
|
+
const scanRangeStartId = useId()
|
|
40
|
+
const scanRangeEndId = useId()
|
|
41
|
+
|
|
42
|
+
const scanRangeStartValue = watch(`${fieldNamePrefix}.scanRangeStart` as Path<T>)
|
|
43
|
+
const scanRangeEndValue = watch(`${fieldNamePrefix}.scanRangeEnd` as Path<T>)
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
<Form.Label>{t('scanningRange')}</Form.Label>
|
|
48
|
+
<Row>
|
|
49
|
+
<Col xs={12} sm={6}>
|
|
50
|
+
<Form.Group controlId={scanRangeStartId}>
|
|
51
|
+
<Form.Label>{t('beforeEventStart')}</Form.Label>
|
|
52
|
+
|
|
53
|
+
<InputGroup hasValidation>
|
|
54
|
+
<InputGroup.Prepend
|
|
55
|
+
className='arrow-up-btn'
|
|
56
|
+
onClick={() => {
|
|
57
|
+
setValue(
|
|
58
|
+
`${fieldNamePrefix}.scanRangeStart` as Path<T>,
|
|
59
|
+
(Number(scanRangeStartValue) + 1) as any,
|
|
60
|
+
)
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
<InputGroup.Text className='py-0 px-3'>
|
|
64
|
+
<IncrementIcon />
|
|
65
|
+
</InputGroup.Text>
|
|
66
|
+
</InputGroup.Prepend>
|
|
67
|
+
|
|
68
|
+
<Controller
|
|
69
|
+
render={({ field: { value, onChange, ref } }) => (
|
|
70
|
+
<Form.Control
|
|
71
|
+
ref={ref}
|
|
72
|
+
type='number'
|
|
73
|
+
min={0}
|
|
74
|
+
step={1}
|
|
75
|
+
onWheel={(event) => event.currentTarget.blur()}
|
|
76
|
+
value={value as string}
|
|
77
|
+
onChange={onChange}
|
|
78
|
+
onFocus={onFocus}
|
|
79
|
+
disabled={isLoading || isOverrides}
|
|
80
|
+
/>
|
|
81
|
+
)}
|
|
82
|
+
control={control}
|
|
83
|
+
name={`${fieldNamePrefix}.scanRangeStart` as Path<T>}
|
|
84
|
+
rules={{
|
|
85
|
+
min: {
|
|
86
|
+
value: 0,
|
|
87
|
+
message: t('Validation:fieldMinNumber', {
|
|
88
|
+
attribute: t('scanRangeStart'),
|
|
89
|
+
min: 0,
|
|
90
|
+
}) as string,
|
|
91
|
+
},
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
|
|
95
|
+
<Form.Control.Feedback type='invalid'>
|
|
96
|
+
{HookFormService.getErrors<T>(
|
|
97
|
+
`${fieldNamePrefix}.scanRangeStart` as Path<T>,
|
|
98
|
+
errors,
|
|
99
|
+
)}
|
|
100
|
+
</Form.Control.Feedback>
|
|
101
|
+
</InputGroup>
|
|
102
|
+
</Form.Group>
|
|
103
|
+
</Col>
|
|
104
|
+
|
|
105
|
+
<Col xs={12} sm={6}>
|
|
106
|
+
<Form.Group controlId={scanRangeEndId}>
|
|
107
|
+
<Form.Label>{t('AfterEventStart')}</Form.Label>
|
|
108
|
+
|
|
109
|
+
<InputGroup hasValidation>
|
|
110
|
+
<InputGroup.Prepend
|
|
111
|
+
className='arrow-up-btn'
|
|
112
|
+
onClick={() => {
|
|
113
|
+
setValue(
|
|
114
|
+
`${fieldNamePrefix}.scanRangeEnd` as Path<T>,
|
|
115
|
+
(Number(scanRangeEndValue) + 1) as any,
|
|
116
|
+
)
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
<InputGroup.Text className='py-0 px-3'>
|
|
120
|
+
<IncrementIcon />
|
|
121
|
+
</InputGroup.Text>
|
|
122
|
+
</InputGroup.Prepend>
|
|
123
|
+
|
|
124
|
+
<Controller
|
|
125
|
+
render={({ field: { value, onChange, ref } }) => (
|
|
126
|
+
<Form.Control
|
|
127
|
+
ref={ref}
|
|
128
|
+
type='number'
|
|
129
|
+
min={0}
|
|
130
|
+
step={1}
|
|
131
|
+
onWheel={(event) => event.currentTarget.blur()}
|
|
132
|
+
value={value && (value as string)}
|
|
133
|
+
onFocus={onFocus}
|
|
134
|
+
onChange={onChange}
|
|
135
|
+
disabled={isLoading || isOverrides}
|
|
136
|
+
/>
|
|
137
|
+
)}
|
|
138
|
+
control={control}
|
|
139
|
+
name={`${fieldNamePrefix}.scanRangeEnd` as Path<T>}
|
|
140
|
+
rules={{
|
|
141
|
+
min: {
|
|
142
|
+
value: 0,
|
|
143
|
+
message: t('Validation:fieldMinNumber', {
|
|
144
|
+
attribute: t('scanRangeEnd'),
|
|
145
|
+
min: 0,
|
|
146
|
+
}) as string,
|
|
147
|
+
},
|
|
148
|
+
}}
|
|
149
|
+
/>
|
|
150
|
+
|
|
151
|
+
<Form.Control.Feedback type='invalid'>
|
|
152
|
+
{HookFormService.getErrors<T>(
|
|
153
|
+
`${fieldNamePrefix}.scanRangeEnd` as Path<T>,
|
|
154
|
+
errors,
|
|
155
|
+
)}
|
|
156
|
+
</Form.Control.Feedback>
|
|
157
|
+
</InputGroup>
|
|
158
|
+
</Form.Group>
|
|
159
|
+
</Col>
|
|
160
|
+
</Row>
|
|
161
|
+
</>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ProductScanRangeControl'
|