@faststore/core 0.3.16 → 0.3.17

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 (53) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/cypress/integration/analytics.test.js +3 -3
  3. package/cypress/integration/plp.test.js +1 -1
  4. package/package.json +4 -4
  5. package/src/Layout.tsx +6 -1
  6. package/src/components/cart/CartItem/CartItem.tsx +2 -2
  7. package/src/components/cart/CartSidebar/CartSidebar.tsx +5 -6
  8. package/src/components/cart/CartSidebar/cart-sidebar.module.scss +2 -0
  9. package/src/components/common/Alert/Alert.tsx +6 -22
  10. package/src/components/common/Footer/Footer.stories.mdx +1 -1
  11. package/src/components/common/Footer/FooterLinks.tsx +16 -12
  12. package/src/components/search/Filter/Facets.stories.mdx +9 -9
  13. package/src/components/search/Filter/Facets.tsx +69 -61
  14. package/src/components/search/Filter/facets.module.scss +16 -16
  15. package/src/components/search/Search.stories.mdx +28 -24
  16. package/src/components/search/SearchDropdown/SearchDropdown.stories.mdx +0 -1
  17. package/src/components/search/SearchInput/SearchInput.stories.mdx +0 -1
  18. package/src/components/search/SearchTop/SearchTop.stories.mdx +0 -1
  19. package/src/components/sections/ProducDetailsContent/ProductDetailsContent.tsx +146 -146
  20. package/src/components/sections/ProductDetails/ProductDetails.tsx +2 -2
  21. package/src/components/ui/Breadcrumb/Breadcrumb.tsx +17 -16
  22. package/src/components/ui/Gift/Gift.tsx +7 -13
  23. package/src/components/ui/SkuSelector/sku-selector.module.scss +1 -1
  24. package/tsconfig.json +1 -1
  25. package/src/components/ui/Accordion/Accordion.stories.mdx +0 -222
  26. package/src/components/ui/Accordion/Accordion.tsx +0 -39
  27. package/src/components/ui/Accordion/AccordionItem.stories.mdx +0 -116
  28. package/src/components/ui/Accordion/AccordionItem.tsx +0 -82
  29. package/src/components/ui/Accordion/accordion.module.scss +0 -65
  30. package/src/components/ui/Accordion/index.ts +0 -2
  31. package/src/components/ui/Alert/Alert.stories.mdx +0 -164
  32. package/src/components/ui/Alert/Alert.tsx +0 -81
  33. package/src/components/ui/Alert/alert.module.scss +0 -93
  34. package/src/components/ui/Alert/index.ts +0 -1
  35. package/src/components/ui/Dropdown/Dropdown.stories.mdx +0 -232
  36. package/src/components/ui/Dropdown/Dropdown.tsx +0 -12
  37. package/src/components/ui/Dropdown/DropdownButton.tsx +0 -20
  38. package/src/components/ui/Dropdown/DropdownItem.stories.mdx +0 -139
  39. package/src/components/ui/Dropdown/DropdownItem.tsx +0 -26
  40. package/src/components/ui/Dropdown/DropdownMenu.stories.mdx +0 -115
  41. package/src/components/ui/Dropdown/DropdownMenu.tsx +0 -34
  42. package/src/components/ui/Dropdown/dropdown.module.scss +0 -101
  43. package/src/components/ui/Dropdown/index.ts +0 -4
  44. package/src/components/ui/Gift/Gift.stories.mdx +0 -99
  45. package/src/components/ui/Gift/gift.module.scss +0 -94
  46. package/src/components/ui/PriceRange/PriceRange.stories.mdx +0 -192
  47. package/src/components/ui/PriceRange/PriceRange.tsx +0 -140
  48. package/src/components/ui/PriceRange/index.ts +0 -1
  49. package/src/components/ui/PriceRange/price-range.module.scss +0 -176
  50. package/src/components/ui/QuantitySelector/QuantitySelector.stories.mdx +0 -246
  51. package/src/components/ui/QuantitySelector/QuantitySelector.tsx +0 -103
  52. package/src/components/ui/QuantitySelector/index.ts +0 -1
  53. package/src/components/ui/QuantitySelector/quantity-selector.module.scss +0 -155
@@ -1,140 +0,0 @@
1
- import { useState, useRef } from 'react'
2
- import {
3
- PriceRange as UIPriceRange,
4
- InputField as UIInputField,
5
- } from '@faststore/ui'
6
- import type { PriceRangeProps } from '@faststore/ui'
7
-
8
- import {
9
- usePriceFormatter,
10
- useFormattedPrice,
11
- } from 'src/sdk/product/useFormattedPrice'
12
-
13
- import styles from './price-range.module.scss'
14
-
15
- type Props = Omit<
16
- PriceRangeProps,
17
- 'formatter' | 'minValueLabelComponent' | 'maxValueLabelComponent'
18
- >
19
-
20
- function PriceRange({ min, max, onEnd, step = 10, ...otherProps }: Props) {
21
- const formatter = usePriceFormatter({ decimals: false })
22
- const minAbsoluteFormatted = useFormattedPrice(Math.round(min.absolute))
23
- const maxAbsoluteFormatted = useFormattedPrice(Math.ceil(max.absolute))
24
-
25
- const inputMinRef = useRef<HTMLInputElement>(null)
26
- const inputMaxRef = useRef<HTMLInputElement>(null)
27
- const priceRangeRef = useRef<{
28
- setPriceRangeValues: (values: { min: number; max: number }) => void
29
- }>()
30
-
31
- const [inputMinError, setInputMinError] = useState<string>()
32
- const [inputMaxError, setInputMaxError] = useState<string>()
33
- const [priceRange, setPriceRange] = useState<{ min: number; max: number }>({
34
- min: Math.round(min.selected),
35
- max: Math.ceil(max.selected),
36
- })
37
-
38
- function onChangePriceRange(value: { min: number; max: number }) {
39
- setInputMinError(undefined)
40
- setInputMaxError(undefined)
41
- setPriceRange({ min: value.min, max: value.max })
42
-
43
- if (inputMinRef.current?.value) {
44
- inputMinRef.current.value = String(value.min)
45
- }
46
-
47
- if (inputMaxRef.current?.value) {
48
- inputMaxRef.current.value = String(value.max)
49
- }
50
- }
51
-
52
- function onChangeInputMin(value: string) {
53
- setInputMinError(undefined)
54
-
55
- if (Number(value) < min.absolute) {
56
- return
57
- }
58
-
59
- if (Number(value) > priceRange.max) {
60
- setInputMinError(`Min price can't be greater than max`)
61
- }
62
-
63
- setPriceRange({ ...priceRange, min: Number(value) })
64
- priceRangeRef.current?.setPriceRangeValues({
65
- ...priceRange,
66
- min: Number(value),
67
- })
68
- }
69
-
70
- function onChangeInputMax(value: string) {
71
- setInputMaxError(undefined)
72
-
73
- if (Number(value) > max.absolute) {
74
- return
75
- }
76
-
77
- if (Number(value) < priceRange.min) {
78
- setInputMaxError(`Max price can't be smaller than min`)
79
- }
80
-
81
- setPriceRange({ ...priceRange, max: Number(value) })
82
- priceRangeRef.current?.setPriceRangeValues({
83
- ...priceRange,
84
- max: Number(value),
85
- })
86
- }
87
-
88
- return (
89
- <div className={styles.fsPriceRange} data-fs-price-range>
90
- <div data-fs-price-range-absolute-values>
91
- <span>{minAbsoluteFormatted}</span>
92
- <span>{maxAbsoluteFormatted}</span>
93
- </div>
94
- <UIPriceRange
95
- ref={priceRangeRef}
96
- min={min}
97
- max={max}
98
- formatter={formatter}
99
- className={styles.fsPriceRange}
100
- onEnd={(value) => {
101
- onEnd?.(value)
102
- onChangePriceRange(value)
103
- }}
104
- {...otherProps}
105
- />
106
- <div data-fs-price-range-inputs>
107
- <UIInputField
108
- id="price-range-min"
109
- step={step}
110
- label="Min"
111
- type="number"
112
- inputMode="numeric"
113
- error={inputMinError}
114
- inputRef={inputMinRef}
115
- min={Math.round(min.absolute)}
116
- max={Math.ceil(priceRange.max)}
117
- value={Math.round(priceRange.min)}
118
- onChange={(e) => onChangeInputMin(e.target.value)}
119
- onBlur={() => !inputMinError && onEnd?.(priceRange)}
120
- />
121
- <UIInputField
122
- id="price-range-max"
123
- label="Max"
124
- step={step}
125
- type="number"
126
- inputMode="numeric"
127
- error={inputMaxError}
128
- inputRef={inputMaxRef}
129
- max={Math.ceil(max.absolute)}
130
- min={Math.round(priceRange.min)}
131
- value={Math.ceil(priceRange.max)}
132
- onChange={(e) => onChangeInputMax(e.target.value)}
133
- onBlur={() => !inputMaxError && onEnd?.(priceRange)}
134
- />
135
- </div>
136
- </div>
137
- )
138
- }
139
-
140
- export default PriceRange
@@ -1 +0,0 @@
1
- export { default } from './PriceRange'
@@ -1,176 +0,0 @@
1
- .fs-price-range {
2
- // --------------------------------------------------------
3
- // Design Tokens for Price Range
4
- // --------------------------------------------------------
5
-
6
- // Default properties
7
- --fs-price-range-height : var(--fs-spacing-2);
8
- --fs-price-range-border-radius : var(--fs-border-radius-pill);
9
- --fs-price-range-margin-bottom : var(--fs-spacing-3);
10
-
11
- --fs-price-range-transition-function : var(--fs-transition-function);
12
- --fs-price-range-transition-property : var(--fs-transition-property);
13
- --fs-price-range-transition-timing : var(--fs-transition-timing);
14
-
15
- // Slider
16
- --fs-price-range-slider-bkg-color : var(--fs-color-neutral-bkg);
17
- --fs-price-range-slider-selection-bkg-color : var(--fs-color-primary-bkg-light-active);
18
-
19
- // Value Label
20
- --fs-price-range-value-label-bottom : var(--fs-spacing-3);
21
- --fs-price-range-value-label-bkg-color : var(--fs-color-body-bkg);
22
-
23
- // Absolute Values
24
- --fs-price-range-absolute-values-text-color : var(--fs-color-disabled-text);
25
-
26
- // Thumb
27
- --fs-price-range-thumb-size : var(--fs-spacing-4);
28
- --fs-price-range-thumb-bkg-color : var(--fs-color-primary-bkg);
29
- --fs-price-range-thumb-bkg-color-hover : var(--fs-color-primary-bkg-hover);
30
- --fs-price-range-thumb-border-radius : var(--fs-border-radius-circle);
31
- --fs-price-range-thumb-border-color : var(--fs-price-range-thumb-bkg-color);
32
- --fs-price-range-thumb-border-color-hover : var(--fs-price-range-thumb-bkg-color-hover);
33
- --fs-price-range-thumb-border-width : var(--fs-border-width);
34
-
35
- // --------------------------------------------------------
36
- // Structural Styles
37
- // --------------------------------------------------------
38
-
39
- [data-fs-slider] {
40
- position: relative;
41
- width: 100%;
42
- height: var(--fs-price-range-height);
43
- margin-bottom: var(--fs-price-range-margin-bottom);
44
- background-color: var(--fs-price-range-slider-bkg-color);
45
- border-radius: var(--fs-price-range-border-radius);
46
- }
47
-
48
- [data-slider-range] {
49
- position: absolute;
50
- height: var(--fs-price-range-height);
51
- background-color: var(--fs-price-range-slider-selection-bkg-color);
52
- border-radius: var(--fs-price-range-border-radius);
53
- }
54
-
55
- [data-price-range-value-label="min"],
56
- [data-price-range-value-label="max"] {
57
- bottom: var(--fs-price-range-value-label-bottom);
58
- padding: var(--fs-spacing-1);
59
- background-color: var(--fs-price-range-value-label-bkg-color);
60
- opacity: 0;
61
- transition: opacity var(--fs-price-range-transition-timing) var(--fs-price-range-transition-function);
62
-
63
- &:hover {
64
- opacity: 1;
65
- }
66
- }
67
-
68
- [data-price-range-value-label="min"] {
69
- text-align: left;
70
- transform: translateX(-1rem);
71
- }
72
-
73
- [data-price-range-value-label="max"] {
74
- text-align: right;
75
- transform: translateX(calc(-100% + 1.25rem));
76
- }
77
-
78
- // Thumb styles for Webkit based browsers (Chrome, Edge)
79
- [data-slider-thumb],
80
- [data-slider-thumb]::-webkit-slider-thumb {
81
- width: var(--fs-price-range-thumb-size);
82
- height: var(--fs-price-range-thumb-size);
83
- pointer-events: auto;
84
- cursor: col-resize;
85
- background-color: var(--fs-price-range-thumb-bkg-color);
86
- border: var(--fs-price-range-thumb-border-width) solid var(--fs-price-range-thumb-border-color);
87
- border-radius: var(--fs-price-range-thumb-border-radius);
88
- -webkit-tap-highlight-color: transparent;
89
- appearance: none;
90
- transition: var(--fs-price-range-transition-property) var(--fs-price-range-transition-timing) var(--fs-price-range-transition-function);
91
-
92
- &:hover {
93
- background-color: var(--fs-price-range-thumb-bkg-color-hover);
94
- border-color: var(--fs-price-range-thumb-border-color-hover);
95
- }
96
- }
97
-
98
- // Thumb styles for Mozilla
99
- [data-slider-thumb]::-moz-range-thumb {
100
- width: var(--fs-price-range-thumb-size);
101
- height: var(--fs-price-range-thumb-size);
102
- pointer-events: auto;
103
- cursor: col-resize;
104
- background-color: var(--fs-price-range-thumb-bkg-color);
105
- border: var(--fs-price-range-thumb-border-width) solid var(--fs-price-range-thumb-border-color);
106
- border-radius: var(--fs-price-range-thumb-radius);
107
- }
108
-
109
- [data-slider-thumb] {
110
- position: absolute;
111
- width: inherit;
112
- height: 0;
113
- margin: calc(var(--fs-price-range-height) / 2) 0;
114
- pointer-events: none;
115
- border: none;
116
- }
117
-
118
- [data-slider-thumb="left"] {
119
- z-index: 1;
120
-
121
- &:hover + [data-price-range-value-label="min"] {
122
- opacity: 1;
123
- }
124
- }
125
-
126
- [data-slider-thumb="right"] {
127
- z-index: 2;
128
-
129
- &:hover + [data-price-range-value-label="max"] {
130
- opacity: 1;
131
- }
132
- }
133
-
134
- [data-price-range-values] {
135
- display: flex;
136
- justify-content: space-between;
137
- margin-top: var(--fs-spacing-3);
138
- margin-bottom: var(--fs-spacing-3);
139
- }
140
-
141
- [data-fs-price-range-inputs] {
142
- display: flex;
143
-
144
- [data-fs-input-field] {
145
- width: 50%;
146
-
147
- input:hover,
148
- input:focus-visible,
149
- input:focus {
150
- z-index: 1;
151
- + label { z-index: 1; }
152
- }
153
-
154
- &:first-of-type {
155
- margin-right: -1px;
156
-
157
- input {
158
- border-top-right-radius: 0;
159
- border-bottom-right-radius: 0;
160
- }
161
- }
162
-
163
- &:last-of-type input {
164
- border-top-left-radius: 0;
165
- border-bottom-left-radius: 0;
166
- }
167
- }
168
- }
169
-
170
- [data-fs-price-range-absolute-values] {
171
- display: flex;
172
- justify-content: space-between;
173
- margin-bottom: var(--fs-spacing-2);
174
- color: var(--fs-price-range-absolute-values-text-color);
175
- }
176
- }
@@ -1,246 +0,0 @@
1
- import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs'
2
-
3
- import QuantitySelector from '.'
4
- import {
5
- TokenTable,
6
- TokenRow,
7
- TokenDivider,
8
- } from 'src/../.storybook/components'
9
-
10
- <Meta
11
- title="Molecules/QuantitySelector"
12
- component={QuantitySelector}
13
- argTypes={{
14
- max: {
15
- type: {
16
- name: 'number',
17
- },
18
- defaultValue: 10,
19
- },
20
- min: {
21
- type: {
22
- name: 'number',
23
- },
24
- defaultValue: 1,
25
- },
26
- initial: {
27
- type: {
28
- name: 'number',
29
- },
30
- defaultValue: 5,
31
- },
32
- disabled: {
33
- type: {
34
- name: 'boolean',
35
- },
36
- defaultValue: false,
37
- },
38
- }}
39
- />
40
-
41
- export const Template = (args) => <QuantitySelector {...args} />
42
-
43
- <header>
44
-
45
- # Quantity Selector
46
-
47
- It's a component that shows a quantity selector, commonly used to add a product to the shopping cart.
48
-
49
- </header>
50
-
51
- ## Overview
52
-
53
- The `QuantitySelector` component uses [FastStore UI QuantitySelector](https://www.faststore.dev/reference/ui/molecules/QuantitySelector) as base.
54
-
55
- <Canvas>
56
- <Story name="Overview-QuantitySelector">{Template.bind({})}</Story>
57
- <Story
58
- name="Overview-Disabled"
59
- args={{
60
- disabled: true,
61
- }}
62
- >
63
- {Template.bind({})}
64
- </Story>
65
- </Canvas>
66
-
67
- ---
68
-
69
- ## Usage
70
-
71
- `import QuantitySelector from '../components/sections/QuantitySelector'`
72
-
73
- <Canvas>
74
- <Story name="QuantitySelector">{Template.bind({})}</Story>
75
- </Canvas>
76
-
77
- <ArgsTable story="QuantitySelector" />
78
-
79
- <TokenTable>
80
- <TokenRow
81
- token="--fs-qty-selector-width"
82
- value="calc(var(--fs-control-tap-size) * 2.7)"
83
- />
84
- <TokenRow
85
- token="--fs-qty-selector-height"
86
- value="calc(var(--fs-control-tap-size) + (var(--fs-qty-selector-border-width) * 2))"
87
- />
88
- <TokenDivider />
89
- <TokenRow token="--fs-qty-selector-shadow" value="none" />
90
- <TokenRow
91
- token="--fs-qty-selector-shadow-hover"
92
- value="0 0 0 var(--fs-border-width) var(--fs-border-color-active)"
93
- />
94
- <TokenDivider />
95
- <TokenRow
96
- token="--fs-qty-selector-bkg-color"
97
- value="var(--fs-color-body-bkg)"
98
- isColor
99
- />
100
- <TokenRow
101
- token="--fs-qty-selector-bkg-color-hover"
102
- value="var(--fs-qty-selector-bkg-color)"
103
- isColor
104
- />
105
- <TokenDivider />
106
- <TokenRow
107
- token="--fs-qty-selector-border-radius"
108
- value="var(--fs-border-radius)"
109
- />
110
- <TokenRow
111
- token="--fs-qty-selector-border-width"
112
- value="var(--fs-border-width)"
113
- />
114
- <TokenRow
115
- token="--fs-qty-selector-border-width-hover"
116
- value="var(--fs-border-width)"
117
- />
118
- <TokenRow
119
- token="--fs-qty-selector-border-color"
120
- value="var(--fs-border-color)"
121
- isColor
122
- />
123
- <TokenRow
124
- token="--fs-qty-selector-border-color-hover"
125
- value="var(--fs-border-color-active)"
126
- isColor
127
- />
128
- <TokenDivider />
129
- <TokenRow
130
- token="--fs-qty-selector-transition-function"
131
- value="var(--fs-transition-function)"
132
- />
133
- <TokenRow
134
- token="--fs-qty-selector-transition-property"
135
- value="var(--fs-transition-property)"
136
- />
137
- <TokenRow
138
- token="--fs-qty-selector-transition-timing "
139
- value="var(--fs-transition-timing)"
140
- />
141
- </TokenTable>
142
-
143
- ---
144
-
145
- ## Nested Elements
146
-
147
- ### Text
148
-
149
- <TokenTable>
150
- <TokenRow
151
- token="--fs-qty-selector-text-size"
152
- value="var(--fs-text-size-base)"
153
- />
154
- <TokenRow
155
- token="--fs-qty-selector-text-color"
156
- value="var(--fs-color-text)"
157
- isColor
158
- />
159
- <TokenRow
160
- token="--fs-qty-selector-text-color-hover"
161
- value="var(--fs-qty-selector-text-color)"
162
- isColor
163
- />
164
- </TokenTable>
165
-
166
- ### Icon
167
-
168
- <TokenTable>
169
- <TokenRow
170
- token="--fs-qty-selector-icon-color"
171
- value="var(--fs-color-link)"
172
- isColor
173
- />
174
- <TokenRow
175
- token="--fs-qty-selector-icon-color-hover"
176
- value="var(--fs-border-color-active)"
177
- isColor
178
- />
179
- </TokenTable>
180
-
181
- ### Button
182
-
183
- <TokenTable>
184
- <TokenRow token="--fs-qty-selector-button-shadow" value="none" />
185
- <TokenRow token="--fs-qty-selector-button-shadow-hover" value="none" />
186
- <TokenRow token="--fs-qty-selector-button-bkg-color" value="transparent" />
187
- <TokenRow
188
- token="--fs-qty-selector-button-bkg-color-hover"
189
- value="var(--fs-color-primary-bkg-light)"
190
- isColor
191
- />
192
- <TokenRow
193
- token="--fs-qty-selector-button-bkg-color-focus"
194
- value="var(--fs-qty-selector-button-bkg-color-hover)"
195
- isColor
196
- />
197
- <TokenRow
198
- token="--fs-qty-selector-button-border-radius"
199
- value="var(--fs-qty-selector-border-radius)"
200
- />
201
- </TokenTable>
202
-
203
- ---
204
-
205
- ## Variants
206
-
207
- ### Disabled
208
-
209
- <Canvas>
210
- <Story
211
- name="Disabled"
212
- args={{
213
- disabled: true,
214
- }}
215
- >
216
- {Template.bind({})}
217
- </Story>
218
- </Canvas>
219
-
220
- <TokenTable>
221
- <TokenRow
222
- token="--fs-qty-selector-disabled-bkg-color"
223
- value="var(--fs-color-disabled-bkg)"
224
- isColor
225
- />
226
- <TokenRow
227
- token="--fs-qty-selector-disabled-text-color"
228
- value="var(--fs-color-disabled-text)"
229
- isColor
230
- />
231
- <TokenRow
232
- token="--fs-qty-selector-disabled-icon-color"
233
- value="var(--fs-border-color-light-disabled)"
234
- isColor
235
- />
236
- <TokenRow
237
- token="--fs-qty-selector-disabled-border-color"
238
- value="var(--fs-qty-selector-disabled-bkg-color)"
239
- isColor
240
- />
241
- <TokenRow
242
- token="--fs-qty-selector-disabled-button-bkg-color"
243
- value="var(--fs-qty-selector-button-bkg-color-hover)"
244
- isColor
245
- />
246
- </TokenTable>
@@ -1,103 +0,0 @@
1
- import { QuantitySelector as UIQuantitySelector } from '@faststore/ui'
2
- import { memo, useEffect, useState } from 'react'
3
-
4
- import Icon from 'src/components/ui/Icon'
5
-
6
- import styles from './quantity-selector.module.scss'
7
-
8
- interface QuantitySelectorProps {
9
- /**
10
- * The maximum value the quantity selector can receive
11
- */
12
- max?: number
13
- /**
14
- * The minimum value the quantity selector can receive
15
- */
16
- min?: number
17
- /**
18
- * The initial value for quantity selector
19
- */
20
- initial?: number
21
- /**
22
- * Specifies that the whole quantity selector component should be disabled.
23
- */
24
- disabled?: boolean
25
- /**
26
- * Event emitted when value is changed
27
- */
28
- onChange?: (value: number) => void
29
- }
30
-
31
- export function QuantitySelector({
32
- max,
33
- min = 1,
34
- initial,
35
- disabled = false,
36
- onChange,
37
- }: QuantitySelectorProps) {
38
- const [quantity, setQuantity] = useState<number>(initial ?? min)
39
- const isLeftDisabled = quantity === min
40
- const isRightDisabled = quantity === max
41
-
42
- const changeQuantity = (increaseValue: number) => {
43
- const quantityValue = validateQuantityBounds(quantity + increaseValue)
44
-
45
- onChange?.(quantityValue)
46
- setQuantity(quantityValue)
47
- }
48
-
49
- const increase = () => changeQuantity(1)
50
-
51
- const decrease = () => changeQuantity(-1)
52
-
53
- function validateQuantityBounds(n: number): number {
54
- const maxValue = min ? Math.max(n, min) : n
55
-
56
- return max ? Math.min(maxValue, max) : maxValue
57
- }
58
-
59
- function validateInput(e: React.FormEvent<HTMLInputElement>) {
60
- const val = e.currentTarget.value
61
-
62
- if (!Number.isNaN(Number(val))) {
63
- setQuantity(() => {
64
- const quantityValue = validateQuantityBounds(Number(val))
65
-
66
- onChange?.(quantityValue)
67
-
68
- return quantityValue
69
- })
70
- }
71
- }
72
-
73
- useEffect(() => {
74
- initial && setQuantity(initial)
75
- }, [initial])
76
-
77
- return (
78
- <UIQuantitySelector
79
- data-fs-quantity-selector={disabled ? 'disabled' : 'true'}
80
- className={styles.fsQuantitySelector}
81
- quantity={quantity}
82
- leftButtonProps={{
83
- onClick: decrease,
84
- disabled: isLeftDisabled || disabled,
85
- icon: <Icon name="Minus" width={16} height={16} weight="bold" />,
86
- testId: 'store-quantity-selector-left',
87
- }}
88
- rightButtonProps={{
89
- onClick: increase,
90
- disabled: isRightDisabled || disabled,
91
- icon: <Icon name="Plus" width={16} height={16} weight="bold" />,
92
- testId: 'store-quantity-selector-right',
93
- }}
94
- inputProps={{
95
- onChange: validateInput,
96
- readOnly: false,
97
- disabled,
98
- }}
99
- />
100
- )
101
- }
102
-
103
- export default memo(QuantitySelector)
@@ -1 +0,0 @@
1
- export { default } from './QuantitySelector'