@faststore/ui 2.0.85-alpha.0 → 2.0.87-alpha.0
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/index.d.ts +0 -2
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/molecules/SkuSelector/styles.scss +204 -0
- package/src/index.ts +0 -2
- package/src/styles/components.scss +1 -0
- package/dist/components/molecules/SkuSelector/SkuSelector.d.ts +0 -58
- package/dist/components/molecules/SkuSelector/SkuSelector.js +0 -15
- package/dist/components/molecules/SkuSelector/SkuSelector.js.map +0 -1
- package/dist/components/molecules/SkuSelector/index.d.ts +0 -2
- package/dist/components/molecules/SkuSelector/index.js +0 -2
- package/dist/components/molecules/SkuSelector/index.js.map +0 -1
- package/src/components/molecules/SkuSelector/SkuSelector.tsx +0 -106
- package/src/components/molecules/SkuSelector/index.tsx +0 -2
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ export { default as TextArea } from './components/atoms/TextArea';
|
|
|
3
3
|
export type { TextAreaProps } from './components/atoms/TextArea';
|
|
4
4
|
export { default as Incentive } from './components/atoms/Incentive';
|
|
5
5
|
export type { IncentiveProps } from './components/atoms/Incentive';
|
|
6
|
-
export { default as SkuSelector } from './components/molecules/SkuSelector';
|
|
7
|
-
export type { SkuSelectorProps } from './components/molecules/SkuSelector';
|
|
8
6
|
export { default as OrderSummary } from './components/molecules/OrderSummary';
|
|
9
7
|
export type { OrderSummaryProps } from './components/molecules/OrderSummary';
|
|
10
8
|
export { default as Bullets } from './components/molecules/Bullets';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@ export * from '@faststore/components';
|
|
|
3
3
|
export { default as TextArea } from './components/atoms/TextArea';
|
|
4
4
|
export { default as Incentive } from './components/atoms/Incentive';
|
|
5
5
|
// Molecules
|
|
6
|
-
export { default as SkuSelector } from './components/molecules/SkuSelector';
|
|
7
6
|
export { default as OrderSummary } from './components/molecules/OrderSummary';
|
|
8
7
|
export { default as Bullets } from './components/molecules/Bullets';
|
|
9
8
|
export { default as SearchInput } from './components/molecules/SearchInput';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AAErC,QAAQ;AACR,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAGjE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAGnE,YAAY;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AAErC,QAAQ;AACR,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAGjE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAGnE,YAAY;AAEZ,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,qCAAqC,CAAA;AAG7E,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAGnE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAM3E,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAGrE,OAAO,EACL,OAAO,IAAI,MAAM,EACjB,aAAa,EACb,WAAW,EACX,UAAU,GACX,MAAM,+BAA+B,CAAA;AAQtC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAG7D,YAAY;AACZ,OAAO,EACL,OAAO,IAAI,UAAU,EACrB,eAAe,EACf,iBAAiB,GAClB,MAAM,mCAAmC,CAAA;AAO1C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAA;AAG1D,QAAQ;AACR,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/ui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.87-alpha.0",
|
|
4
4
|
"description": "A lightweight, framework agnostic component library for React",
|
|
5
5
|
"author": "emersonlaurentino",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"node": "16.18.0",
|
|
59
59
|
"yarn": "1.19.1"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "b3bf59d620318b0bd4511eb4731eb716006c0fb4"
|
|
62
62
|
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
@mixin sku-selector-focus-ring {
|
|
2
|
+
@media not all and (min-resolution: .001dpcm) { // Target only Safari browsers
|
|
3
|
+
@supports (-webkit-appearance:none) {
|
|
4
|
+
// Use `focus` instead of `focus-visible` due to Safari's lack of support
|
|
5
|
+
&:focus > span {
|
|
6
|
+
border-color: var(--fs-border-color-active);
|
|
7
|
+
border-width: var(--fs-border-width-thick);
|
|
8
|
+
|
|
9
|
+
@include focus-ring;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&:focus-visible > span {
|
|
15
|
+
border-color: var(--fs-border-color-active);
|
|
16
|
+
border-width: var(--fs-border-width-thick);
|
|
17
|
+
|
|
18
|
+
@include focus-ring;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[data-fs-sku-selector] {
|
|
23
|
+
// --------------------------------------------------------
|
|
24
|
+
// Design Tokens for Sku Selector
|
|
25
|
+
// --------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
// Default properties
|
|
28
|
+
--fs-sku-selector-row-gap : var(--fs-spacing-2);
|
|
29
|
+
--fs-sku-selector-column-gap : var(--fs-sku-selector-row-gap);
|
|
30
|
+
--fs-sku-selector-text-size : var(--fs-text-size-1);
|
|
31
|
+
|
|
32
|
+
// Option
|
|
33
|
+
--fs-sku-selector-option-width : var(--fs-spacing-7);
|
|
34
|
+
--fs-sku-selector-option-height : var(--fs-sku-selector-option-width);
|
|
35
|
+
--fs-sku-selector-option-bkg-color-hover : var(--fs-color-primary-bkg-light);
|
|
36
|
+
|
|
37
|
+
--fs-sku-selector-option-border-width : var(--fs-border-width-thick);
|
|
38
|
+
--fs-sku-selector-option-border-color : var(--fs-color-neutral-7);
|
|
39
|
+
--fs-sku-selector-option-border-radius : var(--fs-border-radius);
|
|
40
|
+
--fs-sku-selector-option-border-color-hover : var(--fs-border-color-active);
|
|
41
|
+
|
|
42
|
+
--fs-sku-selector-option-checked-border-width : var(--fs-sku-selector-option-border-width);
|
|
43
|
+
--fs-sku-selector-option-checked-border-color : var(--fs-sku-selector-option-border-color-hover);
|
|
44
|
+
--fs-sku-selector-option-checked-box-shadow : 0 0 0 var(--fs-border-width-thickest) var(--fs-color-focus-ring-outline);
|
|
45
|
+
--fs-sku-selector-option-checked-bkg-color : var(--fs-sku-selector-option-bkg-color-hover);
|
|
46
|
+
|
|
47
|
+
--fs-sku-selector-option-disabled-width : var(--fs-border-width);
|
|
48
|
+
--fs-sku-selector-option-disabled-color : var(--fs-color-disabled-text);
|
|
49
|
+
--fs-sku-selector-option-disabled-border-color : var(--fs-border-color-disabled);
|
|
50
|
+
--fs-sku-selector-option-disabled-bkg-color : var(--fs-sku-selector-option-disabled-border-color);
|
|
51
|
+
|
|
52
|
+
--fs-sku-selector-option-transition-timing : var(--fs-transition-timing);
|
|
53
|
+
--fs-sku-selector-option-transition-function : ease;
|
|
54
|
+
|
|
55
|
+
// Image
|
|
56
|
+
--fs-sku-selector-image-width : var(--fs-spacing-6);
|
|
57
|
+
--fs-sku-selector-image-height : var(--fs-sku-selector-image-width);
|
|
58
|
+
--fs-sku-selector-image-border-radius : var(--fs-border-radius-small);
|
|
59
|
+
|
|
60
|
+
// Color
|
|
61
|
+
--fs-sku-selector-color-width : var(--fs-sku-selector-image-width);
|
|
62
|
+
--fs-sku-selector-color-height : var(--fs-sku-selector-color-width);
|
|
63
|
+
--fs-sku-selector-color-border-radius : var(--fs-sku-selector-image-border-radius);
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// --------------------------------------------------------
|
|
67
|
+
// Structural Styles
|
|
68
|
+
// --------------------------------------------------------
|
|
69
|
+
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-wrap: wrap;
|
|
72
|
+
row-gap: var(--fs-sku-selector-row-gap);
|
|
73
|
+
column-gap: var(--fs-sku-selector-column-gap);
|
|
74
|
+
font-size: var(--fs-sku-selector-text-size);
|
|
75
|
+
|
|
76
|
+
[data-fs-sku-selector-title] {
|
|
77
|
+
width: 100%;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
[data-fs-sku-selector-list] {
|
|
81
|
+
display: flex;
|
|
82
|
+
column-gap: var(--fs-spacing-1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
[data-fs-sku-selector-option] {
|
|
86
|
+
position: relative;
|
|
87
|
+
width: var(--fs-sku-selector-option-width);
|
|
88
|
+
height: var(--fs-sku-selector-option-height);
|
|
89
|
+
|
|
90
|
+
[data-fs-sku-selector-option-link] {
|
|
91
|
+
position: absolute;
|
|
92
|
+
width: 100%;
|
|
93
|
+
height: 100%;
|
|
94
|
+
z-index: 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
span {
|
|
98
|
+
position: relative;
|
|
99
|
+
display: flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
justify-content: center;
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
width: 100%;
|
|
104
|
+
height: 100%;
|
|
105
|
+
border: var(--fs-border-width) solid var(--fs-sku-selector-option-border-color);
|
|
106
|
+
border-radius: var(--fs-sku-selector-option-border-radius);
|
|
107
|
+
box-shadow: 0;
|
|
108
|
+
transition: box-shadow var(--fs-sku-selector-option-transition-timing) var(--fs-sku-selector-option-transition-function), background-color var(--fs-sku-selector-option-transition-timing) var(--fs-sku-selector-option-transition-function);
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@include sku-selector-focus-ring;
|
|
113
|
+
|
|
114
|
+
&:hover:not([data-fs-sku-selector-disabled="true"]):not([data-fs-sku-selector-checked="true"]) > span {
|
|
115
|
+
border-color: var(--fs-sku-selector-option-border-color-hover);
|
|
116
|
+
border-width: var(--fs-sku-selector-option-border-width);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&[data-fs-sku-selector-checked="true"] > span {
|
|
120
|
+
border-color: var(--fs-sku-selector-option-checked-border-color);
|
|
121
|
+
border-width: var(--fs-sku-selector-option-checked-border-width);
|
|
122
|
+
box-shadow: var(--fs-sku-selector-option-checked-box-shadow);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&[data-fs-sku-selector-disabled="true"] {
|
|
126
|
+
cursor: not-allowed;
|
|
127
|
+
|
|
128
|
+
[data-fs-sku-selector-option-link] {
|
|
129
|
+
display: none;
|
|
130
|
+
pointer-events: none;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
> span {
|
|
134
|
+
overflow: hidden;
|
|
135
|
+
color: var(--fs-sku-selector-option-disabled-color);
|
|
136
|
+
border-color: var(--fs-sku-selector-option-disabled-border-color);
|
|
137
|
+
pointer-events: none;
|
|
138
|
+
|
|
139
|
+
[data-fs-sku-selector-option-image] { opacity: .7; }
|
|
140
|
+
|
|
141
|
+
&::after {
|
|
142
|
+
position: absolute;
|
|
143
|
+
width: var(--fs-sku-selector-option-disabled-width);
|
|
144
|
+
height: 160%;
|
|
145
|
+
content: "";
|
|
146
|
+
background-color: var(--fs-sku-selector-option-disabled-bkg-color);
|
|
147
|
+
transform: rotate(45deg);
|
|
148
|
+
transform-origin: center;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// --------------------------------------------------------
|
|
155
|
+
// Variants Styles
|
|
156
|
+
// --------------------------------------------------------
|
|
157
|
+
|
|
158
|
+
&[data-fs-sku-selector-variant="color"] {
|
|
159
|
+
[data-fs-sku-selector-option-color] {
|
|
160
|
+
width: var(--fs-sku-selector-color-width);
|
|
161
|
+
height: var(--fs-sku-selector-color-height);
|
|
162
|
+
border-radius: var(--fs-sku-selector-color-border-radius);
|
|
163
|
+
transition: transform var(--fs-sku-selector-option-transition-timing) var(--fs-sku-selector-option-transition-function);
|
|
164
|
+
transform-origin: center center;
|
|
165
|
+
background-color: var(--data-fs-sku-selector-option-color-bkg-color);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
[data-fs-sku-selector-option] {
|
|
169
|
+
&:hover:not([data-fs-sku-selector-disabled="true"]):not([data-fs-sku-selector-checked="true"]) > span [data-fs-sku-selector-option-color] {
|
|
170
|
+
transform: scale(.95);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
&[data-fs-sku-selector-checked="true"] > span [data-fs-sku-selector-option-color] {
|
|
174
|
+
transform: scale(.85);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
&[data-fs-sku-selector-variant="label"] [data-fs-sku-selector-option] {
|
|
180
|
+
&:hover:not([data-fs-sku-selector-disabled="true"]) > span { background-color: var(--fs-sku-selector-option-bkg-color-hover); }
|
|
181
|
+
|
|
182
|
+
&[data-fs-sku-selector-checked="true"] > span { background-color: var(--fs-sku-selector-option-checked-bkg-color); }
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&[data-fs-sku-selector-variant="image"] {
|
|
186
|
+
[data-fs-sku-selector-option-image] {
|
|
187
|
+
width: var(--fs-sku-selector-image-width);
|
|
188
|
+
height: var(--fs-sku-selector-image-height);
|
|
189
|
+
border-radius: var(--fs-sku-selector-image-border-radius);
|
|
190
|
+
transition: transform var(--fs-sku-selector-option-transition-timing) var(--fs-sku-selector-option-transition-function);
|
|
191
|
+
transform-origin: center center;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
[data-fs-sku-selector-option] {
|
|
195
|
+
&:hover:not([data-fs-sku-selector-disabled="true"]):not([data-fs-sku-selector-checked="true"]) > span [data-fs-sku-selector-option-image] {
|
|
196
|
+
transform: scale(.95);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
&[data-fs-sku-selector-checked="true"] > span [data-fs-sku-selector-option-image] {
|
|
200
|
+
transform: scale(.85);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -8,8 +8,6 @@ export { default as Incentive } from './components/atoms/Incentive'
|
|
|
8
8
|
export type { IncentiveProps } from './components/atoms/Incentive'
|
|
9
9
|
|
|
10
10
|
// Molecules
|
|
11
|
-
export { default as SkuSelector } from './components/molecules/SkuSelector'
|
|
12
|
-
export type { SkuSelectorProps } from './components/molecules/SkuSelector'
|
|
13
11
|
|
|
14
12
|
export { default as OrderSummary } from './components/molecules/OrderSummary'
|
|
15
13
|
export type { OrderSummaryProps } from './components/molecules/OrderSummary'
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
@import "../components/molecules/SearchProducts/styles";
|
|
39
39
|
@import "../components/molecules/SearchTop/styles";
|
|
40
40
|
@import "../components/molecules/SelectField/styles";
|
|
41
|
+
@import "../components/molecules/SkuSelector/styles";
|
|
41
42
|
@import "../components/molecules/Table/styles";
|
|
42
43
|
@import "../components/molecules/Tag/styles";
|
|
43
44
|
@import "../components/molecules/Toast/styles";
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { ChangeEventHandler, HTMLAttributes } from 'react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
interface SkuProps {
|
|
4
|
-
/**
|
|
5
|
-
* Alternative text description of the image.
|
|
6
|
-
*/
|
|
7
|
-
alt?: string;
|
|
8
|
-
/**
|
|
9
|
-
* Image URL.
|
|
10
|
-
*/
|
|
11
|
-
src?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Label to describe the option when selected.
|
|
14
|
-
*/
|
|
15
|
-
label: string;
|
|
16
|
-
/**
|
|
17
|
-
* Current value for this option.
|
|
18
|
-
*/
|
|
19
|
-
value: string;
|
|
20
|
-
/**
|
|
21
|
-
* Specifies that this option should be disabled.
|
|
22
|
-
*/
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
}
|
|
25
|
-
type Variant = 'label' | 'image';
|
|
26
|
-
export interface SkuSelectorProps extends HTMLAttributes<HTMLDivElement> {
|
|
27
|
-
/**
|
|
28
|
-
* ID to find this component in testing tools (e.g.: cypress,
|
|
29
|
-
* testing-library, and jest).
|
|
30
|
-
*/
|
|
31
|
-
testId?: string;
|
|
32
|
-
/**
|
|
33
|
-
* ID of the current instance of the component.
|
|
34
|
-
*/
|
|
35
|
-
id?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Specify which variant the component should handle.
|
|
38
|
-
*/
|
|
39
|
-
variant: Variant;
|
|
40
|
-
/**
|
|
41
|
-
* SKU options that should be rendered.
|
|
42
|
-
*/
|
|
43
|
-
options: SkuProps[];
|
|
44
|
-
/**
|
|
45
|
-
* Section label for the SKU selector.
|
|
46
|
-
*/
|
|
47
|
-
label?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Currently active variation's value.
|
|
50
|
-
*/
|
|
51
|
-
activeValue: string;
|
|
52
|
-
/**
|
|
53
|
-
* Function to be triggered when SKU option change.
|
|
54
|
-
*/
|
|
55
|
-
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
56
|
-
}
|
|
57
|
-
declare const SkuSelector: React.ForwardRefExoticComponent<SkuSelectorProps & React.RefAttributes<HTMLDivElement>>;
|
|
58
|
-
export default SkuSelector;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import { Label, RadioGroup } from '@faststore/components';
|
|
3
|
-
const SkuSelector = forwardRef(function SkuSelector({ id, label, variant, onChange, testId = 'store-sku-selector', activeValue, children, ...otherProps }, ref) {
|
|
4
|
-
const radioGroupId = id ? `-${id}` : '';
|
|
5
|
-
return (React.createElement("div", { ref: ref, "data-fs-sku-selector": true, "data-testid": testId, "data-fs-sku-selector-variant": variant, ...otherProps },
|
|
6
|
-
label && (React.createElement(Label, { "data-fs-sku-selector-title": true },
|
|
7
|
-
label,
|
|
8
|
-
": ",
|
|
9
|
-
React.createElement("strong", null, activeValue))),
|
|
10
|
-
React.createElement(RadioGroup, { selectedValue: activeValue, name: `sku-selector-${variant}${radioGroupId}`, onChange: (e) => {
|
|
11
|
-
onChange?.(e);
|
|
12
|
-
} }, children)));
|
|
13
|
-
});
|
|
14
|
-
export default SkuSelector;
|
|
15
|
-
//# sourceMappingURL=SkuSelector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SkuSelector.js","sourceRoot":"","sources":["../../../../src/components/molecules/SkuSelector/SkuSelector.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AA4DzD,MAAM,WAAW,GAAG,UAAU,CAC5B,SAAS,WAAW,CAClB,EACE,EAAE,EACF,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,GAAG,oBAAoB,EAC7B,WAAW,EACX,QAAQ,EACR,GAAG,UAAU,EACd,EACD,GAAG;IAEH,MAAM,YAAY,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IAEvC,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,+CAEK,MAAM,kCACW,OAAO,KACjC,UAAU;QAEb,KAAK,IAAI,CACR,oBAAC,KAAK;YACH,KAAK;;YAAG,oCAAS,WAAW,CAAU,CACjC,CACT;QACD,oBAAC,UAAU,IACT,aAAa,EAAE,WAAW,EAC1B,IAAI,EAAE,gBAAgB,OAAO,GAAG,YAAY,EAAE,EAC9C,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;gBACd,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAA;YACf,CAAC,IAEA,QAAQ,CACE,CACT,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/molecules/SkuSelector/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import type { ChangeEventHandler, HTMLAttributes } from 'react'
|
|
2
|
-
import React, { forwardRef } from 'react'
|
|
3
|
-
import { Label, RadioGroup } from '@faststore/components'
|
|
4
|
-
|
|
5
|
-
interface SkuProps {
|
|
6
|
-
/**
|
|
7
|
-
* Alternative text description of the image.
|
|
8
|
-
*/
|
|
9
|
-
alt?: string
|
|
10
|
-
/**
|
|
11
|
-
* Image URL.
|
|
12
|
-
*/
|
|
13
|
-
src?: string
|
|
14
|
-
/**
|
|
15
|
-
* Label to describe the option when selected.
|
|
16
|
-
*/
|
|
17
|
-
label: string
|
|
18
|
-
/**
|
|
19
|
-
* Current value for this option.
|
|
20
|
-
*/
|
|
21
|
-
value: string
|
|
22
|
-
/**
|
|
23
|
-
* Specifies that this option should be disabled.
|
|
24
|
-
*/
|
|
25
|
-
disabled?: boolean
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// TODO: Add the 'color' variant back once the store supports naturally handling color SKUs.
|
|
29
|
-
type Variant = 'label' | 'image'
|
|
30
|
-
|
|
31
|
-
export interface SkuSelectorProps extends HTMLAttributes<HTMLDivElement> {
|
|
32
|
-
/**
|
|
33
|
-
* ID to find this component in testing tools (e.g.: cypress,
|
|
34
|
-
* testing-library, and jest).
|
|
35
|
-
*/
|
|
36
|
-
testId?: string
|
|
37
|
-
/**
|
|
38
|
-
* ID of the current instance of the component.
|
|
39
|
-
*/
|
|
40
|
-
id?: string
|
|
41
|
-
/**
|
|
42
|
-
* Specify which variant the component should handle.
|
|
43
|
-
*/
|
|
44
|
-
variant: Variant
|
|
45
|
-
/**
|
|
46
|
-
* SKU options that should be rendered.
|
|
47
|
-
*/
|
|
48
|
-
options: SkuProps[]
|
|
49
|
-
/**
|
|
50
|
-
* Section label for the SKU selector.
|
|
51
|
-
*/
|
|
52
|
-
label?: string
|
|
53
|
-
/**
|
|
54
|
-
* Currently active variation's value.
|
|
55
|
-
*/
|
|
56
|
-
activeValue: string
|
|
57
|
-
/**
|
|
58
|
-
* Function to be triggered when SKU option change.
|
|
59
|
-
*/
|
|
60
|
-
onChange?: ChangeEventHandler<HTMLInputElement>
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const SkuSelector = forwardRef<HTMLDivElement, SkuSelectorProps>(
|
|
64
|
-
function SkuSelector(
|
|
65
|
-
{
|
|
66
|
-
id,
|
|
67
|
-
label,
|
|
68
|
-
variant,
|
|
69
|
-
onChange,
|
|
70
|
-
testId = 'store-sku-selector',
|
|
71
|
-
activeValue,
|
|
72
|
-
children,
|
|
73
|
-
...otherProps
|
|
74
|
-
},
|
|
75
|
-
ref
|
|
76
|
-
) {
|
|
77
|
-
const radioGroupId = id ? `-${id}` : ''
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<div
|
|
81
|
-
ref={ref}
|
|
82
|
-
data-fs-sku-selector
|
|
83
|
-
data-testid={testId}
|
|
84
|
-
data-fs-sku-selector-variant={variant}
|
|
85
|
-
{...otherProps}
|
|
86
|
-
>
|
|
87
|
-
{label && (
|
|
88
|
-
<Label data-fs-sku-selector-title>
|
|
89
|
-
{label}: <strong>{activeValue}</strong>
|
|
90
|
-
</Label>
|
|
91
|
-
)}
|
|
92
|
-
<RadioGroup
|
|
93
|
-
selectedValue={activeValue}
|
|
94
|
-
name={`sku-selector-${variant}${radioGroupId}`}
|
|
95
|
-
onChange={(e) => {
|
|
96
|
-
onChange?.(e)
|
|
97
|
-
}}
|
|
98
|
-
>
|
|
99
|
-
{children}
|
|
100
|
-
</RadioGroup>
|
|
101
|
-
</div>
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
export default SkuSelector
|