@nuvler/cli 0.5.16 → 0.5.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.
- package/dist/api/theme-context.js +2 -0
- package/dist/api/theme-context.js.map +1 -1
- package/dist/commands/theme/create.js +1 -1
- package/dist/nuvler.js +15 -1
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/package.json +2 -2
- package/dist/templates/nuvler-default/nuvler.theme.json +1 -1
- package/dist/templates/nuvler-default/package.json +2 -2
- package/dist/templates/nuvler-default/src/contact-form.tsx +172 -0
- package/dist/templates/nuvler-default/src/home-data.ts +30 -0
- package/dist/templates/nuvler-default/src/home.tsx +2 -196
- package/dist/templates/nuvler-default/src/kit-group-selector.tsx +230 -0
- package/dist/templates/nuvler-default/src/kit-selection.ts +39 -0
- package/dist/templates/nuvler-default/src/product-detail-interactive.tsx +407 -114
- package/dist/templates/nuvler-default/src/product-detail.tsx +141 -59
- package/dist/templates/nuvler-default/src/products.tsx +143 -12
- package/dist/templates/nuvler-default/src/theme-component.tsx +29 -3
- package/dist/templates/nuvler-default/src/theme.css +369 -5
- package/dist/templates/nuvler-default/test/kit-detail.test.mjs +292 -0
- package/dist/templates/starter/package.json +2 -2
- package/package.json +3 -3
|
@@ -1347,6 +1347,23 @@ select {
|
|
|
1347
1347
|
cursor: pointer;
|
|
1348
1348
|
line-height: 1;
|
|
1349
1349
|
}
|
|
1350
|
+
.cart-quantity .cart-remove {
|
|
1351
|
+
width: auto;
|
|
1352
|
+
min-width: 0;
|
|
1353
|
+
flex-shrink: 0;
|
|
1354
|
+
padding: 0 10px;
|
|
1355
|
+
border-color: #fecaca;
|
|
1356
|
+
color: #b42318;
|
|
1357
|
+
font-size: 12px;
|
|
1358
|
+
white-space: nowrap;
|
|
1359
|
+
}
|
|
1360
|
+
.cart-quantity .cart-remove:hover {
|
|
1361
|
+
background: #fef2f2;
|
|
1362
|
+
}
|
|
1363
|
+
.cart-quantity .cart-remove:focus-visible {
|
|
1364
|
+
outline: 2px solid #b42318;
|
|
1365
|
+
outline-offset: 2px;
|
|
1366
|
+
}
|
|
1350
1367
|
.cart-quantity .cart-delete {
|
|
1351
1368
|
border-color: #fecaca;
|
|
1352
1369
|
color: #b42318;
|
|
@@ -3846,7 +3863,6 @@ a.mini-banner-card:focus-visible {
|
|
|
3846
3863
|
.product-main-image {
|
|
3847
3864
|
position: relative;
|
|
3848
3865
|
overflow: hidden;
|
|
3849
|
-
aspect-ratio: 1 / 1;
|
|
3850
3866
|
border: 1px solid var(--store-line);
|
|
3851
3867
|
border-radius: var(--border-radius);
|
|
3852
3868
|
background: var(--store-surface);
|
|
@@ -3943,17 +3959,23 @@ a.mini-banner-card:focus-visible {
|
|
|
3943
3959
|
}
|
|
3944
3960
|
}
|
|
3945
3961
|
|
|
3946
|
-
.product-main-image img
|
|
3947
|
-
|
|
3962
|
+
.product-main-image img {
|
|
3963
|
+
display: block;
|
|
3948
3964
|
width: 100%;
|
|
3949
|
-
height:
|
|
3965
|
+
height: auto;
|
|
3950
3966
|
object-fit: contain;
|
|
3951
3967
|
}
|
|
3952
3968
|
|
|
3969
|
+
.product-main-image .store-image-placeholder {
|
|
3970
|
+
width: 100%;
|
|
3971
|
+
height: auto;
|
|
3972
|
+
aspect-ratio: 1 / 1;
|
|
3973
|
+
}
|
|
3974
|
+
|
|
3953
3975
|
.product-main-image > [data-product-main-image] {
|
|
3954
3976
|
display: block;
|
|
3955
3977
|
width: 100%;
|
|
3956
|
-
height:
|
|
3978
|
+
height: auto;
|
|
3957
3979
|
}
|
|
3958
3980
|
|
|
3959
3981
|
.product-main-image > [data-product-main-image][hidden] {
|
|
@@ -5753,3 +5775,345 @@ a.mini-banner-card:focus-visible {
|
|
|
5753
5775
|
transition-duration: 0.01ms !important;
|
|
5754
5776
|
}
|
|
5755
5777
|
}
|
|
5778
|
+
|
|
5779
|
+
.kit-heading {
|
|
5780
|
+
display: flex;
|
|
5781
|
+
flex-wrap: wrap;
|
|
5782
|
+
align-items: center;
|
|
5783
|
+
gap: 8px 12px;
|
|
5784
|
+
}
|
|
5785
|
+
.kit-heading h2 {
|
|
5786
|
+
margin: 0;
|
|
5787
|
+
font-size: 1.15rem;
|
|
5788
|
+
font-weight: 750;
|
|
5789
|
+
}
|
|
5790
|
+
.kit-heading p {
|
|
5791
|
+
flex-basis: 100%;
|
|
5792
|
+
margin: 0;
|
|
5793
|
+
color: var(--store-muted);
|
|
5794
|
+
font-size: 13px;
|
|
5795
|
+
line-height: 1.6;
|
|
5796
|
+
}
|
|
5797
|
+
.kit-groups {
|
|
5798
|
+
display: grid;
|
|
5799
|
+
gap: 12px;
|
|
5800
|
+
margin: 24px 0 16px;
|
|
5801
|
+
}
|
|
5802
|
+
.kit-selector {
|
|
5803
|
+
min-width: 0;
|
|
5804
|
+
border: 1px solid var(--store-line);
|
|
5805
|
+
border-radius: 14px;
|
|
5806
|
+
background: var(--store-surface);
|
|
5807
|
+
overflow: hidden;
|
|
5808
|
+
}
|
|
5809
|
+
.kit-selector[data-complete] {
|
|
5810
|
+
border-color: color-mix(in srgb, var(--color-primary), var(--store-line) 45%);
|
|
5811
|
+
}
|
|
5812
|
+
.kit-group-header {
|
|
5813
|
+
display: flex;
|
|
5814
|
+
align-items: center;
|
|
5815
|
+
gap: 10px;
|
|
5816
|
+
padding: 14px;
|
|
5817
|
+
list-style: none;
|
|
5818
|
+
}
|
|
5819
|
+
summary.kit-group-header {
|
|
5820
|
+
cursor: pointer;
|
|
5821
|
+
}
|
|
5822
|
+
summary.kit-group-header::-webkit-details-marker {
|
|
5823
|
+
display: none;
|
|
5824
|
+
}
|
|
5825
|
+
summary.kit-group-header:focus-visible {
|
|
5826
|
+
outline: 2px solid var(--color-primary);
|
|
5827
|
+
outline-offset: -3px;
|
|
5828
|
+
border-radius: 12px;
|
|
5829
|
+
}
|
|
5830
|
+
summary.kit-group-header:hover {
|
|
5831
|
+
background: color-mix(in srgb, var(--color-primary), transparent 97%);
|
|
5832
|
+
}
|
|
5833
|
+
.kit-group-header .kit-group-image {
|
|
5834
|
+
display: block;
|
|
5835
|
+
width: 44px;
|
|
5836
|
+
height: 44px;
|
|
5837
|
+
flex: 0 0 44px;
|
|
5838
|
+
object-fit: cover;
|
|
5839
|
+
border: 1px solid var(--store-line);
|
|
5840
|
+
border-radius: 10px;
|
|
5841
|
+
}
|
|
5842
|
+
.kit-group-title {
|
|
5843
|
+
display: grid;
|
|
5844
|
+
flex: 1;
|
|
5845
|
+
min-width: 0;
|
|
5846
|
+
gap: 4px;
|
|
5847
|
+
}
|
|
5848
|
+
.kit-group-name {
|
|
5849
|
+
font-size: 14px;
|
|
5850
|
+
font-weight: 750;
|
|
5851
|
+
line-height: 1.4;
|
|
5852
|
+
overflow-wrap: anywhere;
|
|
5853
|
+
}
|
|
5854
|
+
.kit-group-preview {
|
|
5855
|
+
display: -webkit-box;
|
|
5856
|
+
-webkit-line-clamp: 2;
|
|
5857
|
+
-webkit-box-orient: vertical;
|
|
5858
|
+
overflow: hidden;
|
|
5859
|
+
color: var(--store-muted);
|
|
5860
|
+
font-size: 11px;
|
|
5861
|
+
line-height: 1.5;
|
|
5862
|
+
overflow-wrap: anywhere;
|
|
5863
|
+
}
|
|
5864
|
+
.kit-group-status {
|
|
5865
|
+
display: grid;
|
|
5866
|
+
justify-items: end;
|
|
5867
|
+
gap: 3px;
|
|
5868
|
+
flex-shrink: 0;
|
|
5869
|
+
font-size: 10px;
|
|
5870
|
+
color: var(--store-muted);
|
|
5871
|
+
}
|
|
5872
|
+
.kit-group-status > span:first-child {
|
|
5873
|
+
font-size: 12px;
|
|
5874
|
+
font-weight: 750;
|
|
5875
|
+
color: var(--store-text);
|
|
5876
|
+
font-variant-numeric: tabular-nums;
|
|
5877
|
+
}
|
|
5878
|
+
.kit-group-status[data-complete] {
|
|
5879
|
+
color: var(--store-text);
|
|
5880
|
+
}
|
|
5881
|
+
.kit-group-status[data-complete] > span:first-child {
|
|
5882
|
+
padding: 3px 7px;
|
|
5883
|
+
border-radius: 999px;
|
|
5884
|
+
background: color-mix(in srgb, var(--color-primary), transparent 88%);
|
|
5885
|
+
}
|
|
5886
|
+
.kit-group-chevron {
|
|
5887
|
+
width: 16px;
|
|
5888
|
+
height: 16px;
|
|
5889
|
+
flex-shrink: 0;
|
|
5890
|
+
fill: none;
|
|
5891
|
+
stroke: var(--store-muted);
|
|
5892
|
+
stroke-width: 1.8;
|
|
5893
|
+
transition: transform 0.18s;
|
|
5894
|
+
}
|
|
5895
|
+
.kit-group-accordion[open] > .kit-group-header .kit-group-chevron {
|
|
5896
|
+
transform: rotate(180deg);
|
|
5897
|
+
}
|
|
5898
|
+
.kit-group-body {
|
|
5899
|
+
display: grid;
|
|
5900
|
+
gap: 10px;
|
|
5901
|
+
padding: 0 12px 12px;
|
|
5902
|
+
}
|
|
5903
|
+
.kit-group-accordion:not([open]) > .kit-group-body {
|
|
5904
|
+
display: none;
|
|
5905
|
+
}
|
|
5906
|
+
.kit-group-instructions {
|
|
5907
|
+
margin: 0 2px 2px;
|
|
5908
|
+
font-size: 12px;
|
|
5909
|
+
color: var(--store-muted);
|
|
5910
|
+
line-height: 1.5;
|
|
5911
|
+
}
|
|
5912
|
+
.kit-flavor {
|
|
5913
|
+
display: grid;
|
|
5914
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
5915
|
+
align-items: center;
|
|
5916
|
+
gap: 8px 12px;
|
|
5917
|
+
padding: 10px 12px;
|
|
5918
|
+
border: 1px solid var(--store-line);
|
|
5919
|
+
border-radius: 10px;
|
|
5920
|
+
background: var(--store-surface);
|
|
5921
|
+
transition:
|
|
5922
|
+
border-color 0.18s,
|
|
5923
|
+
background 0.18s;
|
|
5924
|
+
}
|
|
5925
|
+
.kit-flavor[data-selected] {
|
|
5926
|
+
border-color: color-mix(in srgb, var(--color-primary), var(--store-line) 45%);
|
|
5927
|
+
background: color-mix(
|
|
5928
|
+
in srgb,
|
|
5929
|
+
var(--color-primary),
|
|
5930
|
+
var(--store-surface) 97%
|
|
5931
|
+
);
|
|
5932
|
+
}
|
|
5933
|
+
.kit-flavor > label {
|
|
5934
|
+
min-width: 0;
|
|
5935
|
+
font-size: 13px;
|
|
5936
|
+
font-weight: 600;
|
|
5937
|
+
line-height: 1.5;
|
|
5938
|
+
overflow-wrap: anywhere;
|
|
5939
|
+
}
|
|
5940
|
+
.kit-flavor[data-unavailable] > label {
|
|
5941
|
+
color: var(--store-muted);
|
|
5942
|
+
}
|
|
5943
|
+
.kit-flavor small {
|
|
5944
|
+
display: block;
|
|
5945
|
+
font-weight: 400;
|
|
5946
|
+
font-size: 11px;
|
|
5947
|
+
}
|
|
5948
|
+
.kit-controls {
|
|
5949
|
+
display: contents;
|
|
5950
|
+
}
|
|
5951
|
+
.kit-stepper {
|
|
5952
|
+
grid-column: 2;
|
|
5953
|
+
display: flex;
|
|
5954
|
+
align-items: center;
|
|
5955
|
+
border: 1px solid var(--store-line);
|
|
5956
|
+
border-radius: 9px;
|
|
5957
|
+
background: var(--store-surface);
|
|
5958
|
+
overflow: hidden;
|
|
5959
|
+
}
|
|
5960
|
+
.kit-controls button {
|
|
5961
|
+
display: grid;
|
|
5962
|
+
place-items: center;
|
|
5963
|
+
min-width: 38px;
|
|
5964
|
+
height: 40px;
|
|
5965
|
+
padding: 0 8px;
|
|
5966
|
+
border: 0;
|
|
5967
|
+
background: transparent;
|
|
5968
|
+
color: var(--store-text);
|
|
5969
|
+
font: inherit;
|
|
5970
|
+
font-size: 14px;
|
|
5971
|
+
font-weight: 600;
|
|
5972
|
+
cursor: pointer;
|
|
5973
|
+
transition: background 0.18s;
|
|
5974
|
+
}
|
|
5975
|
+
.kit-controls button:hover:not(:disabled) {
|
|
5976
|
+
background: color-mix(in srgb, var(--color-primary), transparent 90%);
|
|
5977
|
+
}
|
|
5978
|
+
.kit-stepper input {
|
|
5979
|
+
width: 44px;
|
|
5980
|
+
min-width: 0;
|
|
5981
|
+
height: 40px;
|
|
5982
|
+
padding: 0 2px;
|
|
5983
|
+
border: 0;
|
|
5984
|
+
border-inline: 1px solid var(--store-line);
|
|
5985
|
+
border-radius: 0;
|
|
5986
|
+
background: transparent;
|
|
5987
|
+
color: var(--store-text);
|
|
5988
|
+
text-align: center;
|
|
5989
|
+
font: inherit;
|
|
5990
|
+
font-size: 14px;
|
|
5991
|
+
font-weight: 700;
|
|
5992
|
+
appearance: textfield;
|
|
5993
|
+
}
|
|
5994
|
+
.kit-stepper input::-webkit-inner-spin-button,
|
|
5995
|
+
.kit-stepper input::-webkit-outer-spin-button {
|
|
5996
|
+
-webkit-appearance: none;
|
|
5997
|
+
margin: 0;
|
|
5998
|
+
}
|
|
5999
|
+
.kit-shortcuts {
|
|
6000
|
+
grid-column: 1 / -1;
|
|
6001
|
+
display: flex;
|
|
6002
|
+
justify-content: flex-end;
|
|
6003
|
+
flex-wrap: wrap;
|
|
6004
|
+
gap: 6px;
|
|
6005
|
+
}
|
|
6006
|
+
.kit-shortcuts button {
|
|
6007
|
+
height: 32px;
|
|
6008
|
+
border: 1px solid var(--store-line);
|
|
6009
|
+
border-radius: 8px;
|
|
6010
|
+
color: var(--store-muted);
|
|
6011
|
+
font-size: 11px;
|
|
6012
|
+
}
|
|
6013
|
+
.kit-controls button:focus-visible,
|
|
6014
|
+
.kit-controls input:focus-visible {
|
|
6015
|
+
outline: 2px solid var(--color-primary);
|
|
6016
|
+
outline-offset: -3px;
|
|
6017
|
+
}
|
|
6018
|
+
.kit-controls button:disabled,
|
|
6019
|
+
.kit-controls input:disabled,
|
|
6020
|
+
.product-purchase button:disabled {
|
|
6021
|
+
opacity: 0.4;
|
|
6022
|
+
cursor: not-allowed;
|
|
6023
|
+
}
|
|
6024
|
+
.kit-group-progress {
|
|
6025
|
+
display: grid;
|
|
6026
|
+
gap: 8px;
|
|
6027
|
+
padding: 4px 2px;
|
|
6028
|
+
}
|
|
6029
|
+
.kit-progress {
|
|
6030
|
+
display: block;
|
|
6031
|
+
appearance: none;
|
|
6032
|
+
width: 100%;
|
|
6033
|
+
height: 5px;
|
|
6034
|
+
border: 0;
|
|
6035
|
+
border-radius: 999px;
|
|
6036
|
+
overflow: hidden;
|
|
6037
|
+
background: var(--store-line);
|
|
6038
|
+
color: var(--color-primary);
|
|
6039
|
+
}
|
|
6040
|
+
.kit-progress::-webkit-progress-bar {
|
|
6041
|
+
background: var(--store-line);
|
|
6042
|
+
border-radius: 999px;
|
|
6043
|
+
}
|
|
6044
|
+
.kit-progress::-webkit-progress-value {
|
|
6045
|
+
background: var(--color-primary);
|
|
6046
|
+
border-radius: 999px;
|
|
6047
|
+
transition: width 0.18s;
|
|
6048
|
+
}
|
|
6049
|
+
.kit-progress::-moz-progress-bar {
|
|
6050
|
+
background: var(--color-primary);
|
|
6051
|
+
border-radius: 999px;
|
|
6052
|
+
}
|
|
6053
|
+
.kit-group-progress p {
|
|
6054
|
+
margin: 0;
|
|
6055
|
+
color: var(--store-muted);
|
|
6056
|
+
font-size: 11px;
|
|
6057
|
+
line-height: 1.5;
|
|
6058
|
+
}
|
|
6059
|
+
.kit-purchase-actions {
|
|
6060
|
+
display: grid;
|
|
6061
|
+
gap: 10px;
|
|
6062
|
+
padding: 14px;
|
|
6063
|
+
border: 1px solid var(--store-line);
|
|
6064
|
+
border-radius: 14px;
|
|
6065
|
+
background: var(--store-surface);
|
|
6066
|
+
}
|
|
6067
|
+
.kit-completion-summary {
|
|
6068
|
+
display: grid;
|
|
6069
|
+
gap: 8px;
|
|
6070
|
+
}
|
|
6071
|
+
.kit-completion-summary p {
|
|
6072
|
+
margin: 0;
|
|
6073
|
+
font-size: 12px;
|
|
6074
|
+
color: var(--store-muted);
|
|
6075
|
+
line-height: 1.5;
|
|
6076
|
+
}
|
|
6077
|
+
.kit-completion-summary strong {
|
|
6078
|
+
font-size: 13px;
|
|
6079
|
+
color: var(--store-text);
|
|
6080
|
+
}
|
|
6081
|
+
.kit-completion-groups {
|
|
6082
|
+
display: flex;
|
|
6083
|
+
flex-wrap: wrap;
|
|
6084
|
+
gap: 6px;
|
|
6085
|
+
}
|
|
6086
|
+
.kit-completion-groups > span {
|
|
6087
|
+
padding: 4px 8px;
|
|
6088
|
+
border-radius: 6px;
|
|
6089
|
+
border: 1px solid var(--store-line);
|
|
6090
|
+
font-size: 10px;
|
|
6091
|
+
color: var(--store-muted);
|
|
6092
|
+
}
|
|
6093
|
+
.kit-completion-groups > span[data-complete] {
|
|
6094
|
+
background: color-mix(in srgb, var(--color-primary), transparent 90%);
|
|
6095
|
+
border-color: transparent;
|
|
6096
|
+
color: var(--store-text);
|
|
6097
|
+
}
|
|
6098
|
+
.cart-item small {
|
|
6099
|
+
white-space: pre-line;
|
|
6100
|
+
}
|
|
6101
|
+
@media (max-width: 380px) {
|
|
6102
|
+
.kit-group-header {
|
|
6103
|
+
padding: 12px;
|
|
6104
|
+
gap: 8px;
|
|
6105
|
+
}
|
|
6106
|
+
.kit-flavor {
|
|
6107
|
+
padding: 10px;
|
|
6108
|
+
gap: 8px;
|
|
6109
|
+
}
|
|
6110
|
+
.kit-controls button {
|
|
6111
|
+
min-width: 34px;
|
|
6112
|
+
}
|
|
6113
|
+
.kit-stepper input {
|
|
6114
|
+
width: 38px;
|
|
6115
|
+
}
|
|
6116
|
+
.kit-shortcuts {
|
|
6117
|
+
gap: 4px;
|
|
6118
|
+
}
|
|
6119
|
+
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
5
|
+
import { ProductDetailInteractive } from "../dist/src/product-detail-interactive.js";
|
|
6
|
+
|
|
7
|
+
const product = {
|
|
8
|
+
slug: "kit-50",
|
|
9
|
+
title: "Kit 50",
|
|
10
|
+
sku: "KIT",
|
|
11
|
+
price: 80,
|
|
12
|
+
promotionalPrice: null,
|
|
13
|
+
stockQuantity: null,
|
|
14
|
+
kitSize: 50,
|
|
15
|
+
image: null,
|
|
16
|
+
images: [],
|
|
17
|
+
variantOptions: [{ name: "Sabor", values: ["Frango", "Queijo"] }],
|
|
18
|
+
variants: [
|
|
19
|
+
{
|
|
20
|
+
id: "a",
|
|
21
|
+
name: "Frango",
|
|
22
|
+
sku: "",
|
|
23
|
+
active: true,
|
|
24
|
+
image: null,
|
|
25
|
+
values: [{ name: "Sabor", value: "Frango" }],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "b",
|
|
29
|
+
name: "Queijo",
|
|
30
|
+
sku: "",
|
|
31
|
+
active: false,
|
|
32
|
+
image: null,
|
|
33
|
+
values: [{ name: "Sabor", value: "Queijo" }],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
function render(value) {
|
|
38
|
+
return renderToStaticMarkup(
|
|
39
|
+
createElement(ProductDetailInteractive, {
|
|
40
|
+
product: value,
|
|
41
|
+
onAddToCart() {},
|
|
42
|
+
information: null,
|
|
43
|
+
benefits: null,
|
|
44
|
+
galleryImages: null,
|
|
45
|
+
galleryThumbnails: null,
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
test("kit starts empty, displays its configured size, blocks checkout and inactive flavors", () => {
|
|
50
|
+
const html = render(product);
|
|
51
|
+
assert.match(html, /Monte seu kit/);
|
|
52
|
+
assert.match(html, /50 unidades/);
|
|
53
|
+
assert.match(html, /Selecionados: 0 de 50 · Faltam: 50/);
|
|
54
|
+
assert.match(html, /Indisponível/);
|
|
55
|
+
assert.match(html, /id="kit-b"[^>]*disabled=""/);
|
|
56
|
+
assert.match(html, /<button disabled=""[^>]*>Adicionar ao orçamento/);
|
|
57
|
+
});
|
|
58
|
+
test("ordinary variants keep the single selection interface", () => {
|
|
59
|
+
const html = render({ ...product, kitSize: null });
|
|
60
|
+
assert.doesNotMatch(html, /kit-selector/);
|
|
61
|
+
assert.match(html, /variant-selector/);
|
|
62
|
+
assert.doesNotMatch(html, /<button disabled=""[^>]*>Adicionar ao orçamento/);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("a combo shows three independently counted groups instead of crossed variants", () => {
|
|
66
|
+
const groups = [
|
|
67
|
+
{ id: "snacks", name: "Salgados", quantity: 50 },
|
|
68
|
+
{ id: "drinks", name: "Bebidas", quantity: 1 },
|
|
69
|
+
{ id: "desserts", name: "Churros", quantity: 20 },
|
|
70
|
+
].map((group) => ({
|
|
71
|
+
...group,
|
|
72
|
+
options: [{ id: "a", name: `${group.name} opção`, active: true }],
|
|
73
|
+
}));
|
|
74
|
+
const html = render({ ...product, kitSize: null, kitGroups: groups });
|
|
75
|
+
for (const group of groups) {
|
|
76
|
+
assert.ok(html.includes(`Montagem: ${group.name}`));
|
|
77
|
+
assert.ok(
|
|
78
|
+
html.includes(
|
|
79
|
+
`Selecionados: 0 de ${group.quantity} · Faltam: ${group.quantity}`,
|
|
80
|
+
),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
assert.doesNotMatch(html, /variant-selector/);
|
|
84
|
+
assert.match(html, /<button disabled=""[^>]*>Adicionar ao orçamento/);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
import { KitGroupSelector } from "../dist/src/kit-group-selector.js";
|
|
88
|
+
|
|
89
|
+
test("quantity shortcuts update only their group and remain usable for redistribution", () => {
|
|
90
|
+
const snacks = {
|
|
91
|
+
id: "snacks",
|
|
92
|
+
name: "Salgados",
|
|
93
|
+
quantity: 50,
|
|
94
|
+
options: [{ id: "same", name: "Coxinha", active: true }],
|
|
95
|
+
};
|
|
96
|
+
const drinks = {
|
|
97
|
+
id: "drinks",
|
|
98
|
+
name: "Bebidas",
|
|
99
|
+
quantity: 1,
|
|
100
|
+
options: [{ id: "same", name: "Suco", active: true }],
|
|
101
|
+
};
|
|
102
|
+
const snackKey = JSON.stringify([snacks.id, "same"]);
|
|
103
|
+
const drinkKey = JSON.stringify([drinks.id, "same"]);
|
|
104
|
+
let quantities = { [snackKey]: "50", [drinkKey]: "1" };
|
|
105
|
+
const renderGroup = (group) =>
|
|
106
|
+
KitGroupSelector({
|
|
107
|
+
group,
|
|
108
|
+
grouped: true,
|
|
109
|
+
quantities,
|
|
110
|
+
setQuantities: (update) => {
|
|
111
|
+
quantities = typeof update === "function" ? update(quantities) : update;
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
const nodes = (element) =>
|
|
115
|
+
!element || typeof element !== "object"
|
|
116
|
+
? []
|
|
117
|
+
: Array.isArray(element)
|
|
118
|
+
? element.flatMap(nodes)
|
|
119
|
+
: [element, ...nodes(element.props?.children)];
|
|
120
|
+
const button = (group, label) =>
|
|
121
|
+
nodes(renderGroup(group)).find(
|
|
122
|
+
(element) =>
|
|
123
|
+
element.type === "button" && element.props["aria-label"] === label,
|
|
124
|
+
);
|
|
125
|
+
assert.equal(button(snacks, "Adicionar 5 de Coxinha").props.disabled, true);
|
|
126
|
+
assert.equal(button(snacks, "Retirar 15 de Coxinha").props.disabled, false);
|
|
127
|
+
button(snacks, "Retirar 15 de Coxinha").props.onClick();
|
|
128
|
+
assert.equal(quantities[snackKey], "35");
|
|
129
|
+
assert.equal(quantities[drinkKey], "1");
|
|
130
|
+
assert.equal(button(snacks, "Adicionar 15 de Coxinha").props.disabled, false);
|
|
131
|
+
button(snacks, "Adicionar 15 de Coxinha").props.onClick();
|
|
132
|
+
assert.equal(quantities[snackKey], "50");
|
|
133
|
+
assert.equal(button(drinks, "Retirar 5 de Suco"), undefined);
|
|
134
|
+
assert.equal(button(drinks, "Aumentar Suco").props.disabled, true);
|
|
135
|
+
const html = renderToStaticMarkup(renderGroup(drinks));
|
|
136
|
+
assert.match(html, /Selecionados: 1 de 1 · Faltam: 0/);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("group images appear beside the group heading and remain optional", () => {
|
|
140
|
+
const group = {
|
|
141
|
+
id: "snacks",
|
|
142
|
+
name: "Salgados",
|
|
143
|
+
quantity: 50,
|
|
144
|
+
image: {
|
|
145
|
+
url: "https://example.com/snacks.jpg",
|
|
146
|
+
alt: "Seleção de salgados",
|
|
147
|
+
width: 800,
|
|
148
|
+
height: 600,
|
|
149
|
+
},
|
|
150
|
+
options: [{ id: "a", name: "Coxinha", active: true }],
|
|
151
|
+
};
|
|
152
|
+
const renderGroup = (value) =>
|
|
153
|
+
renderToStaticMarkup(
|
|
154
|
+
createElement(KitGroupSelector, {
|
|
155
|
+
group: value,
|
|
156
|
+
grouped: true,
|
|
157
|
+
quantities: {},
|
|
158
|
+
setQuantities() {},
|
|
159
|
+
}),
|
|
160
|
+
);
|
|
161
|
+
const html = renderGroup(group);
|
|
162
|
+
assert.match(html, /class="kit-group-image"/);
|
|
163
|
+
assert.match(html, /alt="Seleção de salgados"/);
|
|
164
|
+
assert.match(html, /src="https:\/\/example.com\/snacks.jpg"/);
|
|
165
|
+
assert.doesNotMatch(
|
|
166
|
+
renderGroup({ ...group, image: null }),
|
|
167
|
+
/kit-group-image/,
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("only the first combo group starts expanded and the purchase area reports all pending groups", () => {
|
|
172
|
+
const groups = [
|
|
173
|
+
{ id: "s", name: "Salgados", quantity: 50 },
|
|
174
|
+
{ id: "b", name: "Bebidas", quantity: 2 },
|
|
175
|
+
{ id: "c", name: "Churros", quantity: 20 },
|
|
176
|
+
].map((group) => ({
|
|
177
|
+
...group,
|
|
178
|
+
options: [{ id: "a", name: "Opção", active: true }],
|
|
179
|
+
}));
|
|
180
|
+
const html = render({ ...product, kitSize: null, kitGroups: groups });
|
|
181
|
+
const headers = html.match(/<details\b[^>]*>/g) ?? [];
|
|
182
|
+
assert.equal(headers.length, 3);
|
|
183
|
+
assert.match(headers[0], /\bopen=""/);
|
|
184
|
+
assert.doesNotMatch(headers[1], /\bopen=/);
|
|
185
|
+
assert.doesNotMatch(headers[2], /\bopen=/);
|
|
186
|
+
assert.match(html, /0 de 3 grupos completos/);
|
|
187
|
+
for (const group of groups)
|
|
188
|
+
assert.ok(html.includes(`${group.name}: 0/${group.quantity}`));
|
|
189
|
+
assert.doesNotMatch(
|
|
190
|
+
render({ ...product, kitGroups: undefined }),
|
|
191
|
+
/kit-group-accordion/,
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test("small groups hide unsuitable shortcuts and collapsed headers retain selection summaries", () => {
|
|
196
|
+
const group = {
|
|
197
|
+
id: "drinks",
|
|
198
|
+
name: "Bebidas",
|
|
199
|
+
quantity: 2,
|
|
200
|
+
options: [
|
|
201
|
+
{ id: "a", name: "Coca-Cola", active: true },
|
|
202
|
+
{ id: "b", name: "Suco", active: true },
|
|
203
|
+
],
|
|
204
|
+
};
|
|
205
|
+
const quantities = {
|
|
206
|
+
[JSON.stringify([group.id, "a"])]: "1",
|
|
207
|
+
[JSON.stringify([group.id, "b"])]: "1",
|
|
208
|
+
};
|
|
209
|
+
const html = renderToStaticMarkup(
|
|
210
|
+
createElement(KitGroupSelector, {
|
|
211
|
+
group,
|
|
212
|
+
grouped: true,
|
|
213
|
+
initiallyOpen: false,
|
|
214
|
+
quantities,
|
|
215
|
+
setQuantities() {},
|
|
216
|
+
}),
|
|
217
|
+
);
|
|
218
|
+
assert.doesNotMatch(html, /<details[^>]*\bopen=/);
|
|
219
|
+
assert.doesNotMatch(html, /class="kit-shortcuts"/);
|
|
220
|
+
assert.match(html, /1 × Coca-Cola · 1 × Suco/);
|
|
221
|
+
assert.match(html, /data-complete="true"/);
|
|
222
|
+
assert.match(html, /Completo/);
|
|
223
|
+
const limited = renderToStaticMarkup(
|
|
224
|
+
createElement(KitGroupSelector, {
|
|
225
|
+
group: { ...group, quantity: 8 },
|
|
226
|
+
grouped: true,
|
|
227
|
+
quantities: {},
|
|
228
|
+
setQuantities() {},
|
|
229
|
+
}),
|
|
230
|
+
);
|
|
231
|
+
assert.match(limited, /Adicionar 5 de Coca-Cola/);
|
|
232
|
+
assert.doesNotMatch(
|
|
233
|
+
limited,
|
|
234
|
+
/Adicionar 10|Adicionar 15|Retirar 10|Retirar 15/,
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
import { getKitGroupSelection } from "../dist/src/kit-selection.js";
|
|
239
|
+
|
|
240
|
+
test("a group's completion status rejects overflow, invalid input and inactive selections", () => {
|
|
241
|
+
const group = {
|
|
242
|
+
id: "drinks",
|
|
243
|
+
name: "Bebidas",
|
|
244
|
+
quantity: 2,
|
|
245
|
+
options: [
|
|
246
|
+
{ id: "a", name: "Suco", active: true },
|
|
247
|
+
{ id: "b", name: "Refrigerante", active: false },
|
|
248
|
+
],
|
|
249
|
+
};
|
|
250
|
+
const key = JSON.stringify([group.id, "a"]);
|
|
251
|
+
assert.equal(
|
|
252
|
+
getKitGroupSelection(group, true, { [key]: "2" }).complete,
|
|
253
|
+
true,
|
|
254
|
+
);
|
|
255
|
+
for (const raw of ["", "1", "3", "1.5", "-1"])
|
|
256
|
+
assert.equal(
|
|
257
|
+
getKitGroupSelection(group, true, { [key]: raw }).complete,
|
|
258
|
+
false,
|
|
259
|
+
);
|
|
260
|
+
assert.equal(
|
|
261
|
+
getKitGroupSelection(group, true, {
|
|
262
|
+
[JSON.stringify([group.id, "b"])]: "2",
|
|
263
|
+
}).complete,
|
|
264
|
+
false,
|
|
265
|
+
);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
import { ProductDetail } from "../dist/src/product-detail.js";
|
|
269
|
+
import { isValidElement } from "react";
|
|
270
|
+
|
|
271
|
+
test("server-rendered information slots carry stable keys across the client boundary", () => {
|
|
272
|
+
const detail = ProductDetail({
|
|
273
|
+
product: {
|
|
274
|
+
...product,
|
|
275
|
+
categories: [{ name: "Salgados" }],
|
|
276
|
+
brand: "Alice",
|
|
277
|
+
model: "Festa",
|
|
278
|
+
ean: "123",
|
|
279
|
+
stockQuantity: 10,
|
|
280
|
+
sku: "KIT",
|
|
281
|
+
},
|
|
282
|
+
descriptionContent: "Descrição",
|
|
283
|
+
});
|
|
284
|
+
const children =
|
|
285
|
+
detail.props.information.props.children.filter(isValidElement);
|
|
286
|
+
assert.ok(children.length >= 6);
|
|
287
|
+
assert.ok(children.every((child) => child.key !== null));
|
|
288
|
+
assert.equal(
|
|
289
|
+
new Set(children.map((child) => child.key)).size,
|
|
290
|
+
children.length,
|
|
291
|
+
);
|
|
292
|
+
});
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@nuvler/theme-sdk": "^1.4.
|
|
16
|
+
"@nuvler/theme-sdk": "^1.4.7"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": "^19.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@nuvler/cli": "^0.5.
|
|
22
|
+
"@nuvler/cli": "^0.5.17",
|
|
23
23
|
"@types/react": "^19.0.0",
|
|
24
24
|
"react": "^19.0.0",
|
|
25
25
|
"typescript": "^5.9.0"
|