WooCommerce Gutenberg Products Block - Version 1.0.0

Version Description

  • 2018-04-24 =
  • Initial implementation of the Gutenberg Products block.

=

Download this release

Release Info

Developer claudiulodro
Plugin Icon 128x128 WooCommerce Gutenberg Products Block
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

Gruntfile.js ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * This file has a bunch on extra stuff that isn't needed and might not work.
3
+ * That's OK. This is just for compiling the CSS during Products block prototype development. :)
4
+ */
5
+
6
+ /* jshint node:true */
7
+ module.exports = function( grunt ) {
8
+ 'use strict';
9
+
10
+ grunt.initConfig({
11
+
12
+ // Setting folder templates.
13
+ dirs: {
14
+ css: 'assets/css',
15
+ fonts: 'assets/fonts',
16
+ images: 'assets/images',
17
+ js: 'assets/js'
18
+ },
19
+
20
+ // Sass linting with Stylelint.
21
+ stylelint: {
22
+ options: {
23
+ configFile: '.stylelintrc'
24
+ },
25
+ all: [
26
+ '<%= dirs.css %>/*.scss',
27
+ ]
28
+ },
29
+
30
+ // Compile all .scss files.
31
+ sass: {
32
+ compile: {
33
+ options: {
34
+ sourceMap: 'none'
35
+ },
36
+ files: [{
37
+ expand: true,
38
+ cwd: '<%= dirs.css %>/',
39
+ src: ['*.scss'],
40
+ dest: '<%= dirs.css %>/',
41
+ ext: '.css'
42
+ }]
43
+ }
44
+ },
45
+
46
+ // Generate RTL .css files
47
+ rtlcss: {
48
+ woocommerce: {
49
+ expand: true,
50
+ cwd: '<%= dirs.css %>',
51
+ src: [
52
+ '*.css',
53
+ '!select2.css',
54
+ '!*-rtl.css'
55
+ ],
56
+ dest: '<%= dirs.css %>/',
57
+ ext: '-rtl.css'
58
+ }
59
+ },
60
+
61
+ // Minify all .css files.
62
+ cssmin: {
63
+ minify: {
64
+ expand: true,
65
+ cwd: '<%= dirs.css %>/',
66
+ src: ['*.css'],
67
+ dest: '<%= dirs.css %>/',
68
+ ext: '.css'
69
+ }
70
+ },
71
+
72
+ // Watch changes for assets.
73
+ watch: {
74
+ css: {
75
+ files: ['<%= dirs.css %>/*.scss'],
76
+ tasks: ['sass', 'rtlcss', 'cssmin']
77
+ },
78
+ js: {
79
+ files: [
80
+ '<%= dirs.js %>/admin/*js',
81
+ '<%= dirs.js %>/frontend/*js',
82
+ '!<%= dirs.js %>/admin/*.min.js',
83
+ '!<%= dirs.js %>/frontend/*.min.js'
84
+ ],
85
+ tasks: ['jshint', 'uglify']
86
+ }
87
+ },
88
+
89
+ // Autoprefixer.
90
+ postcss: {
91
+ options: {
92
+ processors: [
93
+ require( 'autoprefixer' )({
94
+ browsers: [
95
+ '> 0.1%',
96
+ 'ie 8',
97
+ 'ie 9'
98
+ ]
99
+ })
100
+ ]
101
+ },
102
+ dist: {
103
+ src: [
104
+ '<%= dirs.css %>/*.css'
105
+ ]
106
+ }
107
+ }
108
+ });
109
+
110
+ // Load NPM tasks to be used here
111
+ grunt.loadNpmTasks( 'grunt-sass' );
112
+ grunt.loadNpmTasks( 'grunt-rtlcss' );
113
+ grunt.loadNpmTasks( 'grunt-postcss' );
114
+ grunt.loadNpmTasks( 'grunt-stylelint' );
115
+ grunt.loadNpmTasks( 'grunt-wp-i18n' );
116
+ grunt.loadNpmTasks( 'grunt-checktextdomain' );
117
+ grunt.loadNpmTasks( 'grunt-contrib-jshint' );
118
+ grunt.loadNpmTasks( 'grunt-contrib-uglify' );
119
+ grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
120
+ grunt.loadNpmTasks( 'grunt-contrib-concat' );
121
+ grunt.loadNpmTasks( 'grunt-contrib-watch' );
122
+ grunt.loadNpmTasks( 'grunt-contrib-clean' );
123
+
124
+ // Register tasks
125
+ grunt.registerTask( 'default', [
126
+ 'css',
127
+ ]);
128
+
129
+ grunt.registerTask( 'css', [
130
+ 'sass',
131
+ 'rtlcss',
132
+ 'postcss',
133
+ 'cssmin',
134
+ ]);
135
+
136
+ grunt.registerTask( 'docs', [
137
+ 'clean:apidocs',
138
+ 'shell:apidocs'
139
+ ]);
140
+
141
+ // Only an alias to 'default' task.
142
+ grunt.registerTask( 'dev', [
143
+ 'default'
144
+ ]);
145
+ };
assets/css/gutenberg-products-block-rtl.css ADDED
@@ -0,0 +1 @@
 
1
+ .wc-products-block-preview{overflow:hidden}.wc-products-block-preview .product-preview{float:right;text-align:center;margin-left:3.8%}.wc-products-block-preview.cols-1 .product-preview{float:none;margin-left:0}.wc-products-block-preview.cols-2 .product-preview{width:48%}.wc-products-block-preview.cols-2 .product-preview:nth-of-type(2n){margin-left:0}.wc-products-block-preview.cols-2 .product-preview:nth-of-type(2n+1){clear:both}.wc-products-block-preview.cols-3 .product-preview{width:30.75%}.wc-products-block-preview.cols-3 .product-preview:nth-of-type(3n){margin-left:0}.wc-products-block-preview.cols-3 .product-preview:nth-of-type(3n+1){clear:both}.wc-products-block-preview.cols-4 .product-preview{width:22.05%}.wc-products-block-preview.cols-4 .product-preview:nth-of-type(4n){margin-left:0}.wc-products-block-preview.cols-4 .product-preview:nth-of-type(4n+1){clear:both}.wc-products-block-preview.cols-5 .product-preview{width:16.9%}.wc-products-block-preview.cols-5 .product-preview:nth-of-type(5n){margin-left:0}.wc-products-block-preview.cols-5 .product-preview:nth-of-type(5n+1){clear:both}.wc-products-block-preview.cols-5 .product-preview .product-add-to-cart{font-size:.75em}.wc-products-block-preview.cols-6 .product-preview{width:13.5%}.wc-products-block-preview.cols-6 .product-preview:nth-of-type(6n){margin-left:0}.wc-products-block-preview.cols-6 .product-preview:nth-of-type(6n+1){clear:both}.wc-products-block-preview.cols-6 .product-preview .product-add-to-cart{font-size:.75em}.wc-products-block-preview .product-add-to-cart{display:inline-block;background:#ababab;border-radius:1.5em;color:#fff;cursor:pointer;padding:.75em 1.25em;line-height:1.2em;margin-top:.5em;margin-bottom:1em}.wc-products-settings{background-color:#f8f9f9;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;position:relative}.wc-products-settings__title{margin:0;padding:1.5rem 0;text-align:center;border-bottom:1px solid #e6eaee}.wc-products-settings__title .dashicon{vertical-align:top;margin-left:.25em}.wc-products-settings__footer{margin:2em 0 0;padding:1.5em 0;border-top:1px solid #e6eaee;text-align:center}.wc-products-settings__footer .button{padding-right:1.5em;padding-left:1.5em}.wc-products-display-options--popover+.wc-products-settings__footer,.wc-products-settings-heading+.wc-products-settings__footer{margin-top:-2em;border-top:none}p.wc-products-block-description{margin:2em 0 1.5em 0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:1em;text-align:center}.wc-products-display-options{margin:0 0 2.5em}.wc-products-display-options__option{display:flex;align-items:flex-start;flex-wrap:wrap;margin:0 auto;padding:1.25em 1.5em;max-width:80%;background:#fff;border-width:1px 1px 0;border-style:solid;border-color:#e6eaee;cursor:pointer}.wc-products-display-options__option:last-of-type{border-bottom-width:1px}.wc-products-display-options__option--attribute,.wc-products-display-options__option--best_rated,.wc-products-display-options__option--best_sellers,.wc-products-display-options__option--featured,.wc-products-display-options__option--on_sale{display:none;background-color:#fdfdfd;padding-top:1em;padding-bottom:1em}.wc-products-display-options__option--attribute .wc-products-display-options__option-title,.wc-products-display-options__option--best_rated .wc-products-display-options__option-title,.wc-products-display-options__option--best_sellers .wc-products-display-options__option-title,.wc-products-display-options__option--featured .wc-products-display-options__option-title,.wc-products-display-options__option--on_sale .wc-products-display-options__option-title{font-size:1.15em}.wc-products-display-options__option--attribute .wc-products-display-options__icon .dashicon,.wc-products-display-options__option--best_rated .wc-products-display-options__icon .dashicon,.wc-products-display-options__option--best_sellers .wc-products-display-options__icon .dashicon,.wc-products-display-options__option--featured .wc-products-display-options__icon .dashicon,.wc-products-display-options__option--on_sale .wc-products-display-options__icon .dashicon{height:20px;width:20px}.wc-products-display-options__option--current{cursor:default}.wc-products-display-options__option--current .wc-products-display-options__option-title{color:#86909b}.wc-products-display-options__option-content{width:85%;align-self:center}.wc-products-display-options__option-title{display:block;font-size:1.25em}p.wc-products-display-options__option-description{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:1em;color:#86909b}.wc-products-display-options__icon{align-self:center;margin-right:auto;color:#b9bcc2}.wc-products-display-options__icon .dashicon{height:25px;width:25px}.wc-products-display-options--popover{position:absolute;left:-2em;max-width:60%;margin:0;z-index:999;box-shadow:0 2px 10px 0 rgba(0,0,0,.1);margin-top:-2.15em}.wc-products-display-options--popover .wc-products-display-options__option{margin:0;max-width:none}.wc-products-display-options--popover__arrow{width:2em;height:1.25em;position:absolute;top:-1.15em;left:30%;overflow:hidden}.wc-products-display-options--popover__arrow:after{content:'';position:absolute;width:1.25em;height:1.25em;background:#fff;transform:rotate(-45deg);top:.625em;right:.3125em;box-shadow:0 2px 10px 0 rgba(0,0,0,.1);border:1px solid #e6eaee}.wc-products-display-options--extended .wc-products-display-options__option--attribute,.wc-products-display-options--extended .wc-products-display-options__option--best_rated,.wc-products-display-options--extended .wc-products-display-options__option--best_sellers,.wc-products-display-options--extended .wc-products-display-options__option--featured,.wc-products-display-options--extended .wc-products-display-options__option--on_sale{display:flex}.wc-products-display-options--extended:not(.wc-products-display-options--popover) .wc-products-display-options__option--category{border-bottom-width:1px}.wc-products-display-options--extended:not(.wc-products-display-options--popover) .wc-products-display-options__option--filter{margin-top:.5em}.wc-products-display-options--extended:not(.wc-products-display-options--popover) .wc-products-display-options__option--attribute{margin-bottom:.5em;border-bottom-width:1px}.wc-products-settings-heading{margin:0 0 2em 0;padding:1em 2em;text-align:center;border-bottom:1px solid #e6eaee}.wc-products-list-card{position:relative;margin-right:auto;margin-left:auto;padding:0 1em;overflow:hidden;box-sizing:border-box}.wc-products-list-card .wc-products-list-card__input-wrapper{position:relative;background:#fff;margin:0 0 1em}.wc-products-list-card .wc-products-list-card__input-wrapper .dashicon{position:absolute;top:calc(1em - 1px);right:1em;z-index:1}.wc-products-list-card input[type=search]{position:relative;width:100%;margin:0;padding:1em 3em 1em 1.25em;border-radius:0;background:0 0;border-color:#e6eaee;box-shadow:none;z-index:2}.wc-products-list-card .wc-products-list-card__results{max-height:200px;overflow-y:auto;overflow-x:hidden;box-sizing:border-box}.wc-products-list-card .wc-products-list-card__results ul{list-style:none}.wc-products-list-card .wc-products-list-card__results ul li{margin:0;border:1px solid #e6eaee;border-bottom-width:0}.wc-products-list-card .wc-products-list-card__results ul li:last-child{border-bottom-width:1px}.wc-products-list-card .wc-products-list-card__content{display:flex;align-items:center;flex-direction:row;padding:.75em 1.25em;background:#fff;border-bottom:1px solid #e6eaee}.wc-products-list-card:after{content:'';position:absolute;right:0;bottom:0;width:100%;height:1.5em;background:linear-gradient(rgba(255,255,255,.1) 0,#f8f9f9 100%)}.wc-products-list-card--taxonomy .wc-products-list-card__taxonomy-count{text-align:center;width:30px;font-size:.8em;border:1px solid #e9e9e9;border-radius:1em;color:#aaa}.wc-products-list-card--taxonomy input[type=checkbox]{position:relative;margin-top:0;margin-left:.75em;border-radius:0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li{margin-top:-1px}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li:first-child{margin-top:0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li:last-child{border-bottom-width:0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li ul{display:none;padding:1em 3.25em 1em 1.25em;background:#fdfdfd;border-bottom:1px solid #e6eaee}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li ul li{margin-bottom:.25em;border:none}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li ul li:last-child{margin-bottom:0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li.wc-products-list-card__accordion-open{margin:.5em 0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li.wc-products-list-card__accordion-open:first-child{margin-top:0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li.wc-products-list-card__accordion-open:last-child{margin-bottom:0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li.wc-products-list-card__accordion-open ul{display:block}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li.wc-products-list-card__accordion-open ul li label{display:flex;align-items:center;flex-direction:row}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li.wc-products-list-card__accordion-open ul li .wc-products-list-card__taxonomy-count{margin-right:auto}.wc-products-list-card--taxonomy-category .wc-products-list-card__accordion-button{cursor:pointer;color:#666;margin:0 auto 0 1em;padding:0 .75em 0 0;border:none;border-radius:0;background:0 0;outline:0;text-decoration:none}.wc-products-list-card--taxonomy-category .wc-products-list-card__accordion-button .dashicon{align-self:center;display:flex}.wc-products-list-card--taxonomy-category input[type=checkbox]:indeterminate:before{position:absolute;top:0;bottom:0;left:0;right:0;content:'';margin:42% 20%;width:60%;background:#0073aa}.wc-products-list-card--taxonomy-atributes .wc-products-list-card__results ul{padding:1em 3.25em 1em 1.25em;background:#fdfdfd;border-bottom:1px solid #e6eaee}.wc-products-list-card--taxonomy-atributes .wc-products-list-card__results ul li{margin-bottom:.25em;border:none}.wc-products-list-card--taxonomy-atributes .wc-products-list-card__results ul li .wc-products-list-card__content{padding:0;background:0 0;border:none}.wc-products-list-card--taxonomy-atributes__atribute{margin:-1px 0 0;border-width:1px 1px 0;border-style:solid;border-color:#e6eaee}.wc-products-list-card--taxonomy-atributes__atribute:first-child{margin-top:0}.wc-products-list-card--taxonomy-atributes__atribute.wc-products-list-card__accordion-open{margin-top:.5em;margin-bottom:.5em}.wc-products-list-card--taxonomy-atributes__atribute.wc-products-list-card__accordion-open:first-child{margin-top:0}.wc-products-list-card--taxonomy-atributes__atribute.wc-products-list-card__accordion-open:last-child{margin-bottom:0}.wc-products-list-card--taxonomy-atributes .wc-products-list-card__taxonomy-count{margin-right:auto}.wc-products-list-card--taxonomy-atributes input[type=radio]{position:relative;margin-top:0;margin-left:.75em;border-radius:100%}.wc-products-list-card--specific{overflow:visible}.wc-products-list-card--specific:after{content:none}.wc-products-list-card--specific .wc-products-list-card__item{position:relative;border:none}.wc-products-list-card--specific .wc-products-list-card__item img{margin:0;outline:4px solid #00a0d2;outline-offset:-4px}.wc-products-list-card--specific .wc-products-list-card__item button{position:absolute;top:0;left:0;background:#00a0d2;padding:0;margin:0;border:none;margin-right:auto;line-height:10px;cursor:pointer}.wc-products-list-card--specific .wc-products-list-card__item .dashicon{color:#fff}.wc-products-list-card--specific .wc-products-list-card__input-wrapper{margin:0}.wc-products-list-card--specific .wc-products-list-card__results-wrapper--cols-1 .wc-products-list-card__item{width:100%}.wc-products-list-card--specific .wc-products-list-card__results-wrapper--cols-2 .wc-products-list-card__item{width:50%}.wc-products-list-card--specific .wc-products-list-card__results-wrapper--cols-3 .wc-products-list-card__item{width:33.3333333333%}.wc-products-list-card--specific .wc-products-list-card__results-wrapper--cols-4 .wc-products-list-card__item{width:25%}.wc-products-list-card--specific .wc-products-list-card__results-wrapper--cols-5 .wc-products-list-card__item{width:20%}.wc-products-list-card--specific .wc-products-list-card__results-wrapper--cols-6 .wc-products-list-card__item{width:16.6666666667%}.wc-products-list-card--specific .wc-products-list-card__results{max-height:none;overflow:visible}.wc-products-list-card--specific .wc-products-list-card__results h3{margin:0 0 1em;font-size:1em}.wc-products-list-card--specific .wc-products-list-card__results ul{display:flex;flex-wrap:wrap;margin:0 -.5em -1em}.wc-products-list-card--specific .wc-products-list-card__results ul li{border:none;padding:0 .5em;margin:0 0 1em}.wc-products-list-card--specific .wc-products-list-card__results .wc-products-list-card__content{position:relative;display:block;padding:0;background:0 0;border:none}.wc-products-list-card__search-wrapper{position:relative;margin:0 0 1.5em}.wc-products-list-card__search-results{width:100%;list-style:none;background:#fff;margin:-1px 0 0;border:1px solid #e6eaee;box-shadow:0 1px 3px #e6eaee}.wc-products-list-card__search-results>div{max-height:175px;overflow-y:auto}.wc-products-list-card__search-results .wc-products-list-card__content{position:relative;border-width:1px 0 0;border-style:solid;border-color:#e6eaee;transition:opacity .7s;cursor:pointer;color:#00a0d2}.wc-products-list-card__search-results .wc-products-list-card__content--added{background-color:#f7fcff}.wc-products-list-card__search-results .wc-products-list-card__content:hover{background-color:#f7fcff}.wc-products-list-card__search-results .wc-products-list-card__content--transition-exit-active{opacity:0}.wc-products-list-card__search-results .wc-products-list-card__content:first-child{border-top-width:0}.wc-products-list-card__search-results .wc-products-list-card__content img{object-fit:cover;object-position:center;width:2.5em;height:2.5em;margin:0 0 0 1em}.wc-products-list-card__search-results .wc-products-list-card__content .dashicon{color:#0073aa;margin-right:auto}.wc-products-list-card__search-wrapper--with-results+.wc-products-list-card__results-wrapper .wc-products-list-card__item img{outline:0}.wc-products-list-card__search-wrapper--with-results+.wc-products-list-card__results-wrapper .wc-products-list-card__item button{display:none}.wc-products-list-card__search-no-results{display:block;margin:1em 0 0}.wc-products-list-card__search-no-selected{display:block;margin:-.75em 0 0}.wc-products-list-card__results-wrapper{position:relative;overflow:hidden}@media only screen and (min-width:700px){.wc-products-settings-heading{display:flex;justify-content:space-between}.wc-products-list-card{max-width:480px}}.edit-post-sidebar .wc-products-scope-descriptions{margin-bottom:1.5em;position:relative;padding-right:46px;padding-top:1em;padding-bottom:1.5em;border-bottom:1px solid #e6eaee;display:flex;justify-content:space-between}.edit-post-sidebar h3{font-weight:500;margin-bottom:5px;color:#555d66}.edit-post-sidebar .scope-description{font-size:12px}.edit-post-sidebar .wc-products-scope-description--edit-quicklink{margin-right:1em;min-width:24px}.edit-post-sidebar .wc-products-scope-description--edit-quicklink a{cursor:pointer}
assets/css/gutenberg-products-block.css ADDED
@@ -0,0 +1 @@
 
1
+ .wc-products-block-preview{overflow:hidden}.wc-products-block-preview .product-preview{float:left;text-align:center;margin-right:3.8%}.wc-products-block-preview.cols-1 .product-preview{float:none;margin-right:0}.wc-products-block-preview.cols-2 .product-preview{width:48%}.wc-products-block-preview.cols-2 .product-preview:nth-of-type(2n){margin-right:0}.wc-products-block-preview.cols-2 .product-preview:nth-of-type(2n+1){clear:both}.wc-products-block-preview.cols-3 .product-preview{width:30.75%}.wc-products-block-preview.cols-3 .product-preview:nth-of-type(3n){margin-right:0}.wc-products-block-preview.cols-3 .product-preview:nth-of-type(3n+1){clear:both}.wc-products-block-preview.cols-4 .product-preview{width:22.05%}.wc-products-block-preview.cols-4 .product-preview:nth-of-type(4n){margin-right:0}.wc-products-block-preview.cols-4 .product-preview:nth-of-type(4n+1){clear:both}.wc-products-block-preview.cols-5 .product-preview{width:16.9%}.wc-products-block-preview.cols-5 .product-preview:nth-of-type(5n){margin-right:0}.wc-products-block-preview.cols-5 .product-preview:nth-of-type(5n+1){clear:both}.wc-products-block-preview.cols-5 .product-preview .product-add-to-cart{font-size:.75em}.wc-products-block-preview.cols-6 .product-preview{width:13.5%}.wc-products-block-preview.cols-6 .product-preview:nth-of-type(6n){margin-right:0}.wc-products-block-preview.cols-6 .product-preview:nth-of-type(6n+1){clear:both}.wc-products-block-preview.cols-6 .product-preview .product-add-to-cart{font-size:.75em}.wc-products-block-preview .product-add-to-cart{display:inline-block;background:#ababab;border-radius:1.5em;color:#fff;cursor:pointer;padding:.75em 1.25em;line-height:1.2em;margin-top:.5em;margin-bottom:1em}.wc-products-settings{background-color:#f8f9f9;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;position:relative}.wc-products-settings__title{margin:0;padding:1.5rem 0;text-align:center;border-bottom:1px solid #e6eaee}.wc-products-settings__title .dashicon{vertical-align:top;margin-right:.25em}.wc-products-settings__footer{margin:2em 0 0;padding:1.5em 0;border-top:1px solid #e6eaee;text-align:center}.wc-products-settings__footer .button{padding-left:1.5em;padding-right:1.5em}.wc-products-display-options--popover+.wc-products-settings__footer,.wc-products-settings-heading+.wc-products-settings__footer{margin-top:-2em;border-top:none}p.wc-products-block-description{margin:2em 0 1.5em 0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:1em;text-align:center}.wc-products-display-options{margin:0 0 2.5em}.wc-products-display-options__option{display:flex;align-items:flex-start;flex-wrap:wrap;margin:0 auto;padding:1.25em 1.5em;max-width:80%;background:#fff;border-width:1px 1px 0;border-style:solid;border-color:#e6eaee;cursor:pointer}.wc-products-display-options__option:last-of-type{border-bottom-width:1px}.wc-products-display-options__option--attribute,.wc-products-display-options__option--best_rated,.wc-products-display-options__option--best_sellers,.wc-products-display-options__option--featured,.wc-products-display-options__option--on_sale{display:none;background-color:#fdfdfd;padding-top:1em;padding-bottom:1em}.wc-products-display-options__option--attribute .wc-products-display-options__option-title,.wc-products-display-options__option--best_rated .wc-products-display-options__option-title,.wc-products-display-options__option--best_sellers .wc-products-display-options__option-title,.wc-products-display-options__option--featured .wc-products-display-options__option-title,.wc-products-display-options__option--on_sale .wc-products-display-options__option-title{font-size:1.15em}.wc-products-display-options__option--attribute .wc-products-display-options__icon .dashicon,.wc-products-display-options__option--best_rated .wc-products-display-options__icon .dashicon,.wc-products-display-options__option--best_sellers .wc-products-display-options__icon .dashicon,.wc-products-display-options__option--featured .wc-products-display-options__icon .dashicon,.wc-products-display-options__option--on_sale .wc-products-display-options__icon .dashicon{height:20px;width:20px}.wc-products-display-options__option--current{cursor:default}.wc-products-display-options__option--current .wc-products-display-options__option-title{color:#86909b}.wc-products-display-options__option-content{width:85%;align-self:center}.wc-products-display-options__option-title{display:block;font-size:1.25em}p.wc-products-display-options__option-description{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:1em;color:#86909b}.wc-products-display-options__icon{align-self:center;margin-left:auto;color:#b9bcc2}.wc-products-display-options__icon .dashicon{height:25px;width:25px}.wc-products-display-options--popover{position:absolute;right:-2em;max-width:60%;margin:0;z-index:999;box-shadow:0 2px 10px 0 rgba(0,0,0,.1);margin-top:-2.15em}.wc-products-display-options--popover .wc-products-display-options__option{margin:0;max-width:none}.wc-products-display-options--popover__arrow{width:2em;height:1.25em;position:absolute;top:-1.15em;right:30%;overflow:hidden}.wc-products-display-options--popover__arrow:after{content:'';position:absolute;width:1.25em;height:1.25em;background:#fff;transform:rotate(45deg);top:.625em;left:.3125em;box-shadow:0 2px 10px 0 rgba(0,0,0,.1);border:1px solid #e6eaee}.wc-products-display-options--extended .wc-products-display-options__option--attribute,.wc-products-display-options--extended .wc-products-display-options__option--best_rated,.wc-products-display-options--extended .wc-products-display-options__option--best_sellers,.wc-products-display-options--extended .wc-products-display-options__option--featured,.wc-products-display-options--extended .wc-products-display-options__option--on_sale{display:flex}.wc-products-display-options--extended:not(.wc-products-display-options--popover) .wc-products-display-options__option--category{border-bottom-width:1px}.wc-products-display-options--extended:not(.wc-products-display-options--popover) .wc-products-display-options__option--filter{margin-top:.5em}.wc-products-display-options--extended:not(.wc-products-display-options--popover) .wc-products-display-options__option--attribute{margin-bottom:.5em;border-bottom-width:1px}.wc-products-settings-heading{margin:0 0 2em 0;padding:1em 2em;text-align:center;border-bottom:1px solid #e6eaee}.wc-products-list-card{position:relative;margin-left:auto;margin-right:auto;padding:0 1em;overflow:hidden;box-sizing:border-box}.wc-products-list-card .wc-products-list-card__input-wrapper{position:relative;background:#fff;margin:0 0 1em}.wc-products-list-card .wc-products-list-card__input-wrapper .dashicon{position:absolute;top:calc(1em - 1px);left:1em;z-index:1}.wc-products-list-card input[type=search]{position:relative;width:100%;margin:0;padding:1em 1.25em 1em 3em;border-radius:0;background:0 0;border-color:#e6eaee;box-shadow:none;z-index:2}.wc-products-list-card .wc-products-list-card__results{max-height:200px;overflow-y:auto;overflow-x:hidden;box-sizing:border-box}.wc-products-list-card .wc-products-list-card__results ul{list-style:none}.wc-products-list-card .wc-products-list-card__results ul li{margin:0;border:1px solid #e6eaee;border-bottom-width:0}.wc-products-list-card .wc-products-list-card__results ul li:last-child{border-bottom-width:1px}.wc-products-list-card .wc-products-list-card__content{display:flex;align-items:center;flex-direction:row;padding:.75em 1.25em;background:#fff;border-bottom:1px solid #e6eaee}.wc-products-list-card:after{content:'';position:absolute;left:0;bottom:0;width:100%;height:1.5em;background:linear-gradient(rgba(255,255,255,.1) 0,#f8f9f9 100%)}.wc-products-list-card--taxonomy .wc-products-list-card__taxonomy-count{text-align:center;width:30px;font-size:.8em;border:1px solid #e9e9e9;border-radius:1em;color:#aaa}.wc-products-list-card--taxonomy input[type=checkbox]{position:relative;margin-top:0;margin-right:.75em;border-radius:0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li{margin-top:-1px}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li:first-child{margin-top:0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li:last-child{border-bottom-width:0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li ul{display:none;padding:1em 1.25em 1em 3.25em;background:#fdfdfd;border-bottom:1px solid #e6eaee}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li ul li{margin-bottom:.25em;border:none}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li ul li:last-child{margin-bottom:0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li.wc-products-list-card__accordion-open{margin:.5em 0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li.wc-products-list-card__accordion-open:first-child{margin-top:0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li.wc-products-list-card__accordion-open:last-child{margin-bottom:0}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li.wc-products-list-card__accordion-open ul{display:block}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li.wc-products-list-card__accordion-open ul li label{display:flex;align-items:center;flex-direction:row}.wc-products-list-card--taxonomy-category .wc-products-list-card__results ul li.wc-products-list-card__accordion-open ul li .wc-products-list-card__taxonomy-count{margin-left:auto}.wc-products-list-card--taxonomy-category .wc-products-list-card__accordion-button{cursor:pointer;color:#666;margin:0 1em 0 auto;padding:0 0 0 .75em;border:none;border-radius:0;background:0 0;outline:0;text-decoration:none}.wc-products-list-card--taxonomy-category .wc-products-list-card__accordion-button .dashicon{align-self:center;display:flex}.wc-products-list-card--taxonomy-category input[type=checkbox]:indeterminate:before{position:absolute;top:0;bottom:0;right:0;left:0;content:'';margin:42% 20%;width:60%;background:#0073aa}.wc-products-list-card--taxonomy-atributes .wc-products-list-card__results ul{padding:1em 1.25em 1em 3.25em;background:#fdfdfd;border-bottom:1px solid #e6eaee}.wc-products-list-card--taxonomy-atributes .wc-products-list-card__results ul li{margin-bottom:.25em;border:none}.wc-products-list-card--taxonomy-atributes .wc-products-list-card__results ul li .wc-products-list-card__content{padding:0;background:0 0;border:none}.wc-products-list-card--taxonomy-atributes__atribute{margin:-1px 0 0;border-width:1px 1px 0;border-style:solid;border-color:#e6eaee}.wc-products-list-card--taxonomy-atributes__atribute:first-child{margin-top:0}.wc-products-list-card--taxonomy-atributes__atribute.wc-products-list-card__accordion-open{margin-top:.5em;margin-bottom:.5em}.wc-products-list-card--taxonomy-atributes__atribute.wc-products-list-card__accordion-open:first-child{margin-top:0}.wc-products-list-card--taxonomy-atributes__atribute.wc-products-list-card__accordion-open:last-child{margin-bottom:0}.wc-products-list-card--taxonomy-atributes .wc-products-list-card__taxonomy-count{margin-left:auto}.wc-products-list-card--taxonomy-atributes input[type=radio]{position:relative;margin-top:0;margin-right:.75em;border-radius:100%}.wc-products-list-card--specific{overflow:visible}.wc-products-list-card--specific:after{content:none}.wc-products-list-card--specific .wc-products-list-card__item{position:relative;border:none}.wc-products-list-card--specific .wc-products-list-card__item img{margin:0;outline:4px solid #00a0d2;outline-offset:-4px}.wc-products-list-card--specific .wc-products-list-card__item button{position:absolute;top:0;right:0;background:#00a0d2;padding:0;margin:0;border:none;margin-left:auto;line-height:10px;cursor:pointer}.wc-products-list-card--specific .wc-products-list-card__item .dashicon{color:#fff}.wc-products-list-card--specific .wc-products-list-card__input-wrapper{margin:0}.wc-products-list-card--specific .wc-products-list-card__results-wrapper--cols-1 .wc-products-list-card__item{width:100%}.wc-products-list-card--specific .wc-products-list-card__results-wrapper--cols-2 .wc-products-list-card__item{width:50%}.wc-products-list-card--specific .wc-products-list-card__results-wrapper--cols-3 .wc-products-list-card__item{width:33.3333333333%}.wc-products-list-card--specific .wc-products-list-card__results-wrapper--cols-4 .wc-products-list-card__item{width:25%}.wc-products-list-card--specific .wc-products-list-card__results-wrapper--cols-5 .wc-products-list-card__item{width:20%}.wc-products-list-card--specific .wc-products-list-card__results-wrapper--cols-6 .wc-products-list-card__item{width:16.6666666667%}.wc-products-list-card--specific .wc-products-list-card__results{max-height:none;overflow:visible}.wc-products-list-card--specific .wc-products-list-card__results h3{margin:0 0 1em;font-size:1em}.wc-products-list-card--specific .wc-products-list-card__results ul{display:flex;flex-wrap:wrap;margin:0 -.5em -1em}.wc-products-list-card--specific .wc-products-list-card__results ul li{border:none;padding:0 .5em;margin:0 0 1em}.wc-products-list-card--specific .wc-products-list-card__results .wc-products-list-card__content{position:relative;display:block;padding:0;background:0 0;border:none}.wc-products-list-card__search-wrapper{position:relative;margin:0 0 1.5em}.wc-products-list-card__search-results{width:100%;list-style:none;background:#fff;margin:-1px 0 0;border:1px solid #e6eaee;box-shadow:0 1px 3px #e6eaee}.wc-products-list-card__search-results>div{max-height:175px;overflow-y:auto}.wc-products-list-card__search-results .wc-products-list-card__content{position:relative;border-width:1px 0 0;border-style:solid;border-color:#e6eaee;transition:opacity .7s;cursor:pointer;color:#00a0d2}.wc-products-list-card__search-results .wc-products-list-card__content--added{background-color:#f7fcff}.wc-products-list-card__search-results .wc-products-list-card__content:hover{background-color:#f7fcff}.wc-products-list-card__search-results .wc-products-list-card__content--transition-exit-active{opacity:0}.wc-products-list-card__search-results .wc-products-list-card__content:first-child{border-top-width:0}.wc-products-list-card__search-results .wc-products-list-card__content img{object-fit:cover;object-position:center;width:2.5em;height:2.5em;margin:0 1em 0 0}.wc-products-list-card__search-results .wc-products-list-card__content .dashicon{color:#0073aa;margin-left:auto}.wc-products-list-card__search-wrapper--with-results+.wc-products-list-card__results-wrapper .wc-products-list-card__item img{outline:0}.wc-products-list-card__search-wrapper--with-results+.wc-products-list-card__results-wrapper .wc-products-list-card__item button{display:none}.wc-products-list-card__search-no-results{display:block;margin:1em 0 0}.wc-products-list-card__search-no-selected{display:block;margin:-.75em 0 0}.wc-products-list-card__results-wrapper{position:relative;overflow:hidden}@media only screen and (min-width:700px){.wc-products-settings-heading{display:flex;justify-content:space-between}.wc-products-list-card{max-width:480px}}.edit-post-sidebar .wc-products-scope-descriptions{margin-bottom:1.5em;position:relative;padding-left:46px;padding-top:1em;padding-bottom:1.5em;border-bottom:1px solid #e6eaee;display:flex;justify-content:space-between}.edit-post-sidebar h3{font-weight:500;margin-bottom:5px;color:#555d66}.edit-post-sidebar .scope-description{font-size:12px}.edit-post-sidebar .wc-products-scope-description--edit-quicklink{margin-left:1em;min-width:24px}.edit-post-sidebar .wc-products-scope-description--edit-quicklink a{cursor:pointer}
assets/css/gutenberg-products-block.scss ADDED
@@ -0,0 +1,800 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ $font__sans-serif: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif;
2
+ $color__link: #0073aa;
3
+ $color__link--hover: #00a0d2;
4
+ $color__border: #e6eaee;
5
+ $color__option-description: #86909b;
6
+ $color__option-icon: #b9bcc2;
7
+ $color__alt-background: #fdfdfd;
8
+
9
+ /**
10
+ * Products block preview mode.
11
+ */
12
+
13
+ .wc-products-block-preview {
14
+ overflow: hidden;
15
+
16
+ .product-preview {
17
+ float: left;
18
+ text-align: center;
19
+ margin-right: 3.8%;
20
+ }
21
+
22
+ &.cols-1 .product-preview {
23
+ float: none;
24
+ margin-right: 0;
25
+ }
26
+
27
+ &.cols-2 .product-preview {
28
+ width: 48%;
29
+
30
+ &:nth-of-type(2n) {
31
+ margin-right: 0;
32
+ }
33
+
34
+ &:nth-of-type(2n+1) {
35
+ clear: both;
36
+ }
37
+ }
38
+
39
+ &.cols-3 .product-preview {
40
+ width: 30.75%;
41
+
42
+ &:nth-of-type(3n) {
43
+ margin-right: 0;
44
+ }
45
+
46
+ &:nth-of-type(3n+1) {
47
+ clear: both;
48
+ }
49
+ }
50
+
51
+ &.cols-4 .product-preview {
52
+ width: 22.05%;
53
+
54
+ &:nth-of-type(4n) {
55
+ margin-right: 0;
56
+ }
57
+
58
+ &:nth-of-type(4n+1) {
59
+ clear: both;
60
+ }
61
+ }
62
+
63
+ &.cols-5 .product-preview {
64
+ width: 16.9%;
65
+
66
+ &:nth-of-type(5n) {
67
+ margin-right: 0;
68
+ }
69
+
70
+ &:nth-of-type(5n+1) {
71
+ clear: both;
72
+ }
73
+
74
+ .product-add-to-cart {
75
+ font-size: .75em;
76
+ }
77
+ }
78
+
79
+ &.cols-6 .product-preview {
80
+ width: 13.5%;
81
+
82
+ &:nth-of-type(6n) {
83
+ margin-right: 0;
84
+ }
85
+
86
+ &:nth-of-type(6n+1) {
87
+ clear: both;
88
+ }
89
+
90
+ .product-add-to-cart {
91
+ font-size: .75em;
92
+ }
93
+ }
94
+
95
+ .product-add-to-cart {
96
+ display: inline-block;
97
+ background: #ababab;
98
+ border-radius: 1.5em;
99
+ color: #ffffff;
100
+ cursor: pointer;
101
+ padding: .75em 1.25em;
102
+ line-height: 1.2em;
103
+ margin-top: .5em;
104
+ margin-bottom: 1em;
105
+ }
106
+ }
107
+
108
+ /**
109
+ * General styling
110
+ */
111
+
112
+ .wc-products-settings {
113
+ background-color: #f8f9f9;
114
+ font-family: $font__sans-serif;
115
+ font-size: 13px;
116
+ position: relative;
117
+ }
118
+
119
+ /* Block title */
120
+ .wc-products-settings__title {
121
+ margin: 0;
122
+ padding: 1.5rem 0;
123
+ text-align: center;
124
+ border-bottom: 1px solid $color__border;
125
+
126
+ .dashicon {
127
+ vertical-align: top;
128
+ margin-right: .25em;
129
+ }
130
+ }
131
+
132
+ /* Block footer */
133
+ .wc-products-settings__footer {
134
+ margin: 2em 0 0;
135
+ padding: 1.5em 0;
136
+ border-top: 1px solid $color__border;
137
+ text-align: center;
138
+
139
+ .button {
140
+ padding-left: 1.5em;
141
+ padding-right: 1.5em;
142
+ }
143
+ }
144
+
145
+ .wc-products-settings-heading +
146
+ .wc-products-settings__footer,
147
+ .wc-products-display-options--popover +
148
+ .wc-products-settings__footer {
149
+ margin-top: -2em;
150
+ border-top: none;
151
+ }
152
+
153
+ /**
154
+ * Menu
155
+ */
156
+
157
+ /* Select an option description */
158
+ p.wc-products-block-description {
159
+ margin: 2em 0 1.5em 0;
160
+ font-family: $font__sans-serif;
161
+ font-size: 1em;
162
+ text-align: center;
163
+ }
164
+
165
+ /* Select option */
166
+ .wc-products-display-options {
167
+ margin: 0 0 2.5em;
168
+ }
169
+
170
+ .wc-products-display-options__option {
171
+ display: flex;
172
+ align-items: flex-start;
173
+ flex-wrap: wrap;
174
+ margin: 0 auto;
175
+ padding: 1.25em 1.5em;
176
+ max-width: 80%;
177
+ background: #fff;
178
+ border-width: 1px 1px 0;
179
+ border-style: solid;
180
+ border-color: $color__border;
181
+ cursor: pointer;
182
+
183
+ &:last-of-type {
184
+ border-bottom-width: 1px;
185
+ }
186
+
187
+ &--featured,
188
+ &--best_sellers,
189
+ &--best_rated,
190
+ &--on_sale,
191
+ &--attribute {
192
+ display: none;
193
+ background-color: $color__alt-background;
194
+ padding-top: 1em;
195
+ padding-bottom: 1em;
196
+
197
+ .wc-products-display-options__option-title {
198
+ font-size: 1.15em;
199
+ }
200
+
201
+ .wc-products-display-options__icon {
202
+ .dashicon {
203
+ height: 20px;
204
+ width: 20px;
205
+ }
206
+ }
207
+ }
208
+
209
+ &--current {
210
+ cursor: default;
211
+
212
+ .wc-products-display-options__option-title {
213
+ color: $color__option-description;
214
+ }
215
+ }
216
+ }
217
+
218
+ .wc-products-display-options__option-content {
219
+ width: 85%;
220
+ align-self: center;
221
+ }
222
+
223
+ .wc-products-display-options__option-title {
224
+ display: block;
225
+ font-size: 1.25em;
226
+ }
227
+
228
+ p.wc-products-display-options__option-description {
229
+ margin: 0;
230
+ font-family: $font__sans-serif;
231
+ font-size: 1em;
232
+ color: $color__option-description;
233
+ }
234
+
235
+ .wc-products-display-options__icon {
236
+ align-self: center;
237
+ margin-left: auto;
238
+ color: $color__option-icon;
239
+
240
+ .dashicon {
241
+ height: 25px;
242
+ width: 25px;
243
+ }
244
+ }
245
+
246
+ /* Select options popover */
247
+ .wc-products-display-options--popover {
248
+ position: absolute;
249
+ right: -2em;
250
+ max-width: 60%;
251
+ margin: 0;
252
+ z-index: 999;
253
+ box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.1);
254
+ margin-top: -2.15em;
255
+
256
+ .wc-products-display-options__option {
257
+ margin: 0;
258
+ max-width: none;
259
+ }
260
+ }
261
+
262
+ .wc-products-display-options--popover__arrow {
263
+ width: 2em;
264
+ height: 1.25em;
265
+ position: absolute;
266
+ top: -1.15em;
267
+ right: 30%;
268
+ overflow: hidden;
269
+
270
+ &:after {
271
+ content: '';
272
+ position: absolute;
273
+ width: 1.25em;
274
+ height: 1.25em;
275
+ background: #fff;
276
+ transform: rotate(45deg);
277
+ top: .625em;
278
+ left: .3125em;
279
+ box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.1);
280
+ border: 1px solid $color__border;
281
+ }
282
+ }
283
+
284
+ /* Select options extended */
285
+ .wc-products-display-options--extended {
286
+ .wc-products-display-options__option {
287
+ &--featured,
288
+ &--best_sellers,
289
+ &--best_rated,
290
+ &--on_sale,
291
+ &--attribute {
292
+ display: flex;
293
+ }
294
+ }
295
+
296
+ &:not(.wc-products-display-options--popover) {
297
+ .wc-products-display-options__option {
298
+ &--category {
299
+ border-bottom-width: 1px;
300
+ }
301
+
302
+ &--filter {
303
+ margin-top: .5em;
304
+ }
305
+
306
+ &--attribute {
307
+ margin-bottom: .5em;
308
+ border-bottom-width: 1px;
309
+ }
310
+ }
311
+ }
312
+ }
313
+
314
+ /**
315
+ * Settings heading
316
+ */
317
+
318
+ .wc-products-settings-heading {
319
+ margin: 0 0 2em 0;
320
+ padding: 1em 2em;
321
+ text-align: center;
322
+ border-bottom: 1px solid $color__border;
323
+ }
324
+
325
+ /**
326
+ * List Card
327
+ */
328
+
329
+ .wc-products-list-card {
330
+ position: relative;
331
+ margin-left: auto;
332
+ margin-right: auto;
333
+ padding: 0 1em;
334
+ overflow: hidden;
335
+ box-sizing: border-box;
336
+
337
+ .wc-products-list-card__input-wrapper {
338
+ position: relative;
339
+ background: #ffffff;
340
+ margin: 0 0 1em;
341
+
342
+ .dashicon {
343
+ position: absolute;
344
+ top: calc( 1em - 1px );
345
+ left: 1em;
346
+ z-index: 1;
347
+ }
348
+ }
349
+
350
+ input[type="search"] {
351
+ position: relative;
352
+ width: 100%;
353
+ margin: 0;
354
+ padding: 1em 1.25em 1em 3em; // Override Gutenberg input style.
355
+ border-radius: 0;
356
+ background: transparent;
357
+ border-color: $color__border;
358
+ box-shadow: none;
359
+ z-index: 2;
360
+ }
361
+
362
+ .wc-products-list-card__results {
363
+ max-height: 200px;
364
+ overflow-y: auto;
365
+ overflow-x: hidden;
366
+ box-sizing: border-box;
367
+
368
+ ul {
369
+ list-style: none;
370
+
371
+ li {
372
+ margin: 0;
373
+ border: 1px solid $color__border;
374
+ border-bottom-width: 0;
375
+
376
+ &:last-child {
377
+ border-bottom-width: 1px;
378
+ }
379
+ }
380
+ }
381
+ }
382
+
383
+ .wc-products-list-card__content {
384
+ display: flex;
385
+ align-items: center;
386
+ flex-direction: row;
387
+ padding: .75em 1.25em;
388
+ background: #fff;
389
+ border-bottom: 1px solid $color__border;
390
+ }
391
+
392
+ &:after {
393
+ content: '';
394
+ position: absolute;
395
+ left: 0;
396
+ bottom: 0;
397
+ width: 100%;
398
+ height: 1.5em;
399
+ background: linear-gradient( rgba( 255, 255, 255, .1 ) 0, #f8f9f9 100% );
400
+ }
401
+ }
402
+
403
+ /**
404
+ * Categories / Attributes
405
+ */
406
+
407
+ .wc-products-list-card--taxonomy {
408
+ .wc-products-list-card__taxonomy-count {
409
+ text-align: center;
410
+ width: 30px;
411
+ font-size: .8em;
412
+ border: 1px solid #e9e9e9;
413
+ border-radius: 1em;
414
+ color: #aaa;
415
+ }
416
+
417
+ input[type="checkbox"] {
418
+ position: relative;
419
+ margin-top: 0;
420
+ margin-right: .75em;
421
+ border-radius: 0;
422
+ }
423
+ }
424
+
425
+ /**
426
+ * Categories
427
+ */
428
+
429
+ .wc-products-list-card--taxonomy-category {
430
+ .wc-products-list-card__results {
431
+ ul {
432
+ li {
433
+ margin-top: -1px;
434
+
435
+ &:first-child {
436
+ margin-top: 0;
437
+ }
438
+
439
+ &:last-child {
440
+ border-bottom-width: 0;
441
+ }
442
+
443
+ ul {
444
+ display: none;
445
+ padding: 1em 1.25em 1em 3.25em;
446
+ background: $color__alt-background;
447
+ border-bottom: 1px solid $color__border;
448
+
449
+ li {
450
+ margin-bottom: .25em;
451
+ border: none;
452
+
453
+ &:last-child {
454
+ margin-bottom: 0;
455
+ }
456
+ }
457
+ }
458
+
459
+ &.wc-products-list-card__accordion-open {
460
+ margin: .5em 0;
461
+
462
+ &:first-child {
463
+ margin-top: 0;
464
+ }
465
+
466
+ &:last-child {
467
+ margin-bottom: 0;
468
+ }
469
+
470
+ ul {
471
+ display: block;
472
+
473
+ li {
474
+ label {
475
+ display: flex;
476
+ align-items: center;
477
+ flex-direction: row;
478
+ }
479
+
480
+ .wc-products-list-card__taxonomy-count {
481
+ margin-left: auto;
482
+ }
483
+ }
484
+ }
485
+ }
486
+ }
487
+ }
488
+ }
489
+
490
+ .wc-products-list-card__accordion-button {
491
+ cursor: pointer;
492
+ color: #666;
493
+ margin: 0 1em 0 auto;
494
+ padding: 0 0 0 .75em;
495
+ border: none;
496
+ border-radius: 0;
497
+ background: none;
498
+ outline: none;
499
+ text-decoration: none;
500
+
501
+ .dashicon {
502
+ align-self: center;
503
+ display: flex;
504
+ }
505
+ }
506
+
507
+ input[type="checkbox"] {
508
+ &:indeterminate {
509
+ &:before {
510
+ position: absolute;
511
+ top: 0;
512
+ bottom: 0;
513
+ right: 0;
514
+ left: 0;
515
+ content: '';
516
+ margin: 42% 20%;
517
+ width: 60%;
518
+ background: $color__link;
519
+ }
520
+ }
521
+ }
522
+ }
523
+
524
+ /**
525
+ * Attributes
526
+ */
527
+
528
+ .wc-products-list-card--taxonomy-atributes {
529
+ .wc-products-list-card__results {
530
+ ul {
531
+ padding: 1em 1.25em 1em 3.25em;
532
+ background: $color__alt-background;
533
+ border-bottom: 1px solid $color__border;
534
+
535
+ li {
536
+ margin-bottom: .25em;
537
+ border: none;
538
+
539
+ .wc-products-list-card__content {
540
+ padding: 0;
541
+ background: transparent;
542
+ border: none;
543
+ }
544
+ }
545
+ }
546
+ }
547
+
548
+ &__atribute {
549
+ margin: -1px 0 0;
550
+ border-width: 1px 1px 0;
551
+ border-style: solid;
552
+ border-color: $color__border;
553
+
554
+ &:first-child {
555
+ margin-top: 0;
556
+ }
557
+
558
+ &.wc-products-list-card__accordion-open {
559
+ margin-top: .5em;
560
+ margin-bottom: .5em;
561
+
562
+ &:first-child {
563
+ margin-top: 0;
564
+ }
565
+
566
+ &:last-child {
567
+ margin-bottom: 0;
568
+ }
569
+ }
570
+ }
571
+
572
+ .wc-products-list-card__taxonomy-count {
573
+ margin-left: auto;
574
+ }
575
+
576
+ input[type="radio"] {
577
+ position: relative;
578
+ margin-top: 0;
579
+ margin-right: .75em;
580
+ border-radius: 100%;
581
+ }
582
+ }
583
+
584
+ /**
585
+ * Specific
586
+ */
587
+
588
+ .wc-products-list-card--specific {
589
+ overflow: visible;
590
+
591
+ &:after {
592
+ content: none;
593
+ }
594
+
595
+ .wc-products-list-card__item {
596
+ position: relative;
597
+ border: none;
598
+
599
+ img {
600
+ margin: 0;
601
+ outline: 4px solid $color__link--hover;
602
+ outline-offset: -4px;
603
+ }
604
+
605
+ button {
606
+ position: absolute;
607
+ top: 0;
608
+ right: 0;
609
+ background: $color__link--hover;
610
+ padding: 0;
611
+ margin: 0;
612
+ border: none;
613
+ margin-left: auto;
614
+ line-height: 10px;
615
+ cursor: pointer;
616
+ }
617
+
618
+ .dashicon {
619
+ color: #ffffff;
620
+ }
621
+ }
622
+
623
+ .wc-products-list-card__input-wrapper {
624
+ margin: 0;
625
+ }
626
+
627
+ .wc-products-list-card__results-wrapper {
628
+ @for $i from 1 through 6 {
629
+ $width: percentage( 1 / $i );
630
+
631
+ &--cols-#{$i} {
632
+ .wc-products-list-card__item {
633
+ width: $width;
634
+ }
635
+ }
636
+ }
637
+ }
638
+
639
+ .wc-products-list-card__results {
640
+ max-height: none;
641
+ overflow: visible;
642
+
643
+ h3 {
644
+ margin: 0 0 1em;
645
+ font-size: 1em;
646
+ }
647
+
648
+ ul {
649
+ display: flex;
650
+ flex-wrap: wrap;
651
+ margin: 0 -.5em -1em;
652
+
653
+ li {
654
+ border: none;
655
+ padding: 0 .5em;
656
+ margin: 0 0 1em;
657
+ }
658
+ }
659
+
660
+ .wc-products-list-card__content {
661
+ position: relative;
662
+ display: block;
663
+ padding: 0;
664
+ background: transparent;
665
+ border: none;
666
+ }
667
+ }
668
+ }
669
+
670
+ .wc-products-list-card__search-wrapper {
671
+ position: relative;
672
+ margin: 0 0 1.5em;
673
+ }
674
+
675
+ .wc-products-list-card__search-results {
676
+ width: 100%;
677
+ list-style: none;
678
+ background: #ffffff;
679
+ margin: -1px 0 0;
680
+ border: 1px solid $color__border;
681
+ box-shadow: 0 1px 3px $color__border;
682
+
683
+ > div {
684
+ max-height: 175px;
685
+ overflow-y: auto;
686
+ }
687
+
688
+ .wc-products-list-card__content {
689
+ position: relative;
690
+ border-width: 1px 0 0;
691
+ border-style: solid;
692
+ border-color: $color__border;
693
+ transition: opacity .7s;
694
+ cursor: pointer;
695
+ color: $color__link--hover;
696
+
697
+ &--added {
698
+ background-color: lighten( $color__link, 65% );
699
+ }
700
+
701
+ &:hover {
702
+ background-color: lighten( $color__link, 65% );
703
+ }
704
+
705
+ &--transition-exit-active {
706
+ opacity: 0;
707
+ }
708
+
709
+ &:first-child {
710
+ border-top-width: 0;
711
+ }
712
+
713
+ img {
714
+ object-fit: cover;
715
+ object-position: center;
716
+ width: 2.5em;
717
+ height: 2.5em;
718
+ margin: 0 1em 0 0;
719
+ }
720
+
721
+ .dashicon {
722
+ color: $color__link;
723
+ margin-left: auto;
724
+ }
725
+ }
726
+ }
727
+
728
+ .wc-products-list-card__search-wrapper--with-results +
729
+ .wc-products-list-card__results-wrapper {
730
+ .wc-products-list-card__item {
731
+ img {
732
+ outline: none;
733
+ }
734
+
735
+ button {
736
+ display: none;
737
+ }
738
+ }
739
+ }
740
+
741
+ .wc-products-list-card__search-no-results {
742
+ display: block;
743
+ margin: 1em 0 0;
744
+ }
745
+
746
+ .wc-products-list-card__search-no-selected {
747
+ display: block;
748
+ margin: -.75em 0 0;
749
+ }
750
+
751
+ .wc-products-list-card__results-wrapper {
752
+ position: relative;
753
+ overflow: hidden;
754
+ }
755
+
756
+ @media only screen and (min-width: 700px) {
757
+ .wc-products-settings-heading {
758
+ display: flex;
759
+ justify-content: space-between;
760
+ }
761
+
762
+ .wc-products-list-card {
763
+ max-width: 480px;
764
+ }
765
+ }
766
+
767
+ /**
768
+ * Sidebar area
769
+ */
770
+ .edit-post-sidebar {
771
+ .wc-products-scope-descriptions {
772
+ margin-bottom: 1.5em;
773
+ position: relative;
774
+ padding-left: 46px;
775
+ padding-top: 1em;
776
+ padding-bottom: 1.5em;
777
+ border-bottom: 1px solid $color__border;
778
+ display: flex;
779
+ justify-content: space-between;
780
+ }
781
+
782
+ h3 {
783
+ font-weight: 500;
784
+ margin-bottom: 5px;
785
+ color: #555d66;
786
+ }
787
+
788
+ .scope-description {
789
+ font-size: 12px;
790
+ }
791
+
792
+ .wc-products-scope-description--edit-quicklink {
793
+ margin-left: 1em;
794
+ min-width: 24px;
795
+
796
+ a {
797
+ cursor: pointer;
798
+ }
799
+ }
800
+ }
assets/js/products-block.js ADDED
@@ -0,0 +1,2754 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /******/ (function(modules) { // webpackBootstrap
2
+ /******/ // The module cache
3
+ /******/ var installedModules = {};
4
+ /******/
5
+ /******/ // The require function
6
+ /******/ function __webpack_require__(moduleId) {
7
+ /******/
8
+ /******/ // Check if module is in cache
9
+ /******/ if(installedModules[moduleId]) {
10
+ /******/ return installedModules[moduleId].exports;
11
+ /******/ }
12
+ /******/ // Create a new module (and put it into the cache)
13
+ /******/ var module = installedModules[moduleId] = {
14
+ /******/ i: moduleId,
15
+ /******/ l: false,
16
+ /******/ exports: {}
17
+ /******/ };
18
+ /******/
19
+ /******/ // Execute the module function
20
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21
+ /******/
22
+ /******/ // Flag the module as loaded
23
+ /******/ module.l = true;
24
+ /******/
25
+ /******/ // Return the exports of the module
26
+ /******/ return module.exports;
27
+ /******/ }
28
+ /******/
29
+ /******/
30
+ /******/ // expose the modules object (__webpack_modules__)
31
+ /******/ __webpack_require__.m = modules;
32
+ /******/
33
+ /******/ // expose the module cache
34
+ /******/ __webpack_require__.c = installedModules;
35
+ /******/
36
+ /******/ // define getter function for harmony exports
37
+ /******/ __webpack_require__.d = function(exports, name, getter) {
38
+ /******/ if(!__webpack_require__.o(exports, name)) {
39
+ /******/ Object.defineProperty(exports, name, {
40
+ /******/ configurable: false,
41
+ /******/ enumerable: true,
42
+ /******/ get: getter
43
+ /******/ });
44
+ /******/ }
45
+ /******/ };
46
+ /******/
47
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
48
+ /******/ __webpack_require__.n = function(module) {
49
+ /******/ var getter = module && module.__esModule ?
50
+ /******/ function getDefault() { return module['default']; } :
51
+ /******/ function getModuleExports() { return module; };
52
+ /******/ __webpack_require__.d(getter, 'a', getter);
53
+ /******/ return getter;
54
+ /******/ };
55
+ /******/
56
+ /******/ // Object.prototype.hasOwnProperty.call
57
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
58
+ /******/
59
+ /******/ // __webpack_public_path__
60
+ /******/ __webpack_require__.p = "";
61
+ /******/
62
+ /******/ // Load entry module and return exports
63
+ /******/ return __webpack_require__(__webpack_require__.s = 0);
64
+ /******/ })
65
+ /************************************************************************/
66
+ /******/ ([
67
+ /* 0 */
68
+ /***/ (function(module, exports, __webpack_require__) {
69
+
70
+ "use strict";
71
+
72
+
73
+ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
74
+
75
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
76
+
77
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
78
+
79
+ var _specificSelect = __webpack_require__(1);
80
+
81
+ var _categorySelect = __webpack_require__(2);
82
+
83
+ var _attributeSelect = __webpack_require__(3);
84
+
85
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
86
+
87
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
88
+
89
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
90
+
91
+ var __ = wp.i18n.__;
92
+ var RawHTML = wp.element.RawHTML;
93
+ var _wp$blocks = wp.blocks,
94
+ registerBlockType = _wp$blocks.registerBlockType,
95
+ InspectorControls = _wp$blocks.InspectorControls,
96
+ BlockControls = _wp$blocks.BlockControls;
97
+ var _wp$components = wp.components,
98
+ Toolbar = _wp$components.Toolbar,
99
+ withAPIData = _wp$components.withAPIData,
100
+ Dropdown = _wp$components.Dropdown,
101
+ Dashicon = _wp$components.Dashicon,
102
+ RangeControl = _wp$components.RangeControl,
103
+ Tooltip = _wp$components.Tooltip,
104
+ SelectControl = _wp$components.SelectControl;
105
+
106
+
107
+ /**
108
+ * A setting has the following properties:
109
+ * title - Display title of the setting.
110
+ * description - Display description of the setting.
111
+ * value - Display setting slug to set when selected.
112
+ * group_container - (optional) If set the setting is a parent container.
113
+ */
114
+ var PRODUCTS_BLOCK_DISPLAY_SETTINGS = {
115
+ 'specific': {
116
+ title: __('Individual products'),
117
+ description: __('Hand-pick which products to display'),
118
+ value: 'specific'
119
+ },
120
+ 'category': {
121
+ title: __('Product category'),
122
+ description: __('Display products from a specific category or multiple categories'),
123
+ value: 'category'
124
+ },
125
+ 'filter': {
126
+ title: __('Filter products'),
127
+ description: __('E.g. featured products, or products with a specific attribute like size or color'),
128
+ value: 'filter',
129
+ group_container: 'filter'
130
+ },
131
+ 'featured': {
132
+ title: __('Featured products'),
133
+ description: '',
134
+ value: 'featured'
135
+ },
136
+ 'on_sale': {
137
+ title: __('On sale'),
138
+ description: '',
139
+ value: 'on_sale'
140
+ },
141
+ 'attribute': {
142
+ title: __('Attribute'),
143
+ description: '',
144
+ value: 'attribute'
145
+ },
146
+ 'all': {
147
+ title: __('All products'),
148
+ description: __('Display all products ordered chronologically, alphabetically, by price, by rating or by sales'),
149
+ value: 'all'
150
+ }
151
+ };
152
+
153
+ /**
154
+ * One option from the list of all available ways to display products.
155
+ */
156
+
157
+ var ProductsBlockSettingsEditorDisplayOption = function (_React$Component) {
158
+ _inherits(ProductsBlockSettingsEditorDisplayOption, _React$Component);
159
+
160
+ function ProductsBlockSettingsEditorDisplayOption() {
161
+ _classCallCheck(this, ProductsBlockSettingsEditorDisplayOption);
162
+
163
+ return _possibleConstructorReturn(this, (ProductsBlockSettingsEditorDisplayOption.__proto__ || Object.getPrototypeOf(ProductsBlockSettingsEditorDisplayOption)).apply(this, arguments));
164
+ }
165
+
166
+ _createClass(ProductsBlockSettingsEditorDisplayOption, [{
167
+ key: 'render',
168
+ value: function render() {
169
+ var _this2 = this;
170
+
171
+ var icon = 'arrow-right-alt2';
172
+
173
+ if ('filter' === this.props.value && this.props.extended) {
174
+ icon = 'arrow-down-alt2';
175
+ }
176
+
177
+ var classes = 'wc-products-display-options__option wc-products-display-options__option--' + this.props.value;
178
+
179
+ if (this.props.current === this.props.value) {
180
+ icon = 'yes';
181
+ classes += ' wc-products-display-options__option--current';
182
+ }
183
+
184
+ return wp.element.createElement(
185
+ 'div',
186
+ { className: classes, onClick: function onClick() {
187
+ _this2.props.current !== _this2.props.value && _this2.props.update_display_callback(_this2.props.value);
188
+ } },
189
+ wp.element.createElement(
190
+ 'div',
191
+ { className: 'wc-products-display-options__option-content' },
192
+ wp.element.createElement(
193
+ 'span',
194
+ { className: 'wc-products-display-options__option-title' },
195
+ this.props.title
196
+ ),
197
+ wp.element.createElement(
198
+ 'p',
199
+ { className: 'wc-products-display-options__option-description' },
200
+ this.props.description
201
+ )
202
+ ),
203
+ wp.element.createElement(
204
+ 'div',
205
+ { className: 'wc-products-display-options__icon' },
206
+ wp.element.createElement(Dashicon, { icon: icon })
207
+ )
208
+ );
209
+ }
210
+ }]);
211
+
212
+ return ProductsBlockSettingsEditorDisplayOption;
213
+ }(React.Component);
214
+
215
+ /**
216
+ * A list of all available ways to display products.
217
+ */
218
+
219
+
220
+ var ProductsBlockSettingsEditorDisplayOptions = function (_React$Component2) {
221
+ _inherits(ProductsBlockSettingsEditorDisplayOptions, _React$Component2);
222
+
223
+ /**
224
+ * Constructor.
225
+ */
226
+ function ProductsBlockSettingsEditorDisplayOptions(props) {
227
+ _classCallCheck(this, ProductsBlockSettingsEditorDisplayOptions);
228
+
229
+ var _this3 = _possibleConstructorReturn(this, (ProductsBlockSettingsEditorDisplayOptions.__proto__ || Object.getPrototypeOf(ProductsBlockSettingsEditorDisplayOptions)).call(this, props));
230
+
231
+ _this3.setWrapperRef = _this3.setWrapperRef.bind(_this3);
232
+ _this3.handleClickOutside = _this3.handleClickOutside.bind(_this3);
233
+ return _this3;
234
+ }
235
+
236
+ /**
237
+ * Hook in the listener for closing menu when clicked outside.
238
+ */
239
+
240
+
241
+ _createClass(ProductsBlockSettingsEditorDisplayOptions, [{
242
+ key: 'componentDidMount',
243
+ value: function componentDidMount() {
244
+ if (this.props.existing) {
245
+ document.addEventListener('mousedown', this.handleClickOutside);
246
+ }
247
+ }
248
+
249
+ /**
250
+ * Remove the listener for closing menu when clicked outside.
251
+ */
252
+
253
+ }, {
254
+ key: 'componentWillUnmount',
255
+ value: function componentWillUnmount() {
256
+ if (this.props.existing) {
257
+ document.removeEventListener('mousedown', this.handleClickOutside);
258
+ }
259
+ }
260
+
261
+ /**
262
+ * Set the wrapper reference.
263
+ *
264
+ * @param node DOMNode
265
+ */
266
+
267
+ }, {
268
+ key: 'setWrapperRef',
269
+ value: function setWrapperRef(node) {
270
+ this.wrapperRef = node;
271
+ }
272
+
273
+ /**
274
+ * Close the menu when user clicks outside the search area.
275
+ */
276
+
277
+ }, {
278
+ key: 'handleClickOutside',
279
+ value: function handleClickOutside(evt) {
280
+ if (this.wrapperRef && !this.wrapperRef.contains(event.target) && 'wc-products-settings-heading__change-button button-link' !== event.target.getAttribute('class')) {
281
+ this.props.closeMenu();
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Render the list of options.
287
+ */
288
+
289
+ }, {
290
+ key: 'render',
291
+ value: function render() {
292
+ var classes = 'wc-products-display-options';
293
+
294
+ if (this.props.extended) {
295
+ classes += ' wc-products-display-options--extended';
296
+ }
297
+
298
+ if (this.props.existing) {
299
+ classes += ' wc-products-display-options--popover';
300
+ }
301
+
302
+ var display_settings = [];
303
+ for (var setting_key in PRODUCTS_BLOCK_DISPLAY_SETTINGS) {
304
+ display_settings.push(wp.element.createElement(ProductsBlockSettingsEditorDisplayOption, _extends({}, PRODUCTS_BLOCK_DISPLAY_SETTINGS[setting_key], { update_display_callback: this.props.update_display_callback, extended: this.props.extended, current: this.props.current })));
305
+ }
306
+
307
+ var arrow = wp.element.createElement('span', { className: 'wc-products-display-options--popover__arrow' });
308
+ var description = wp.element.createElement(
309
+ 'p',
310
+ { className: 'wc-products-block-description' },
311
+ __('Choose which products you\'d like to display:')
312
+ );
313
+
314
+ return wp.element.createElement(
315
+ 'div',
316
+ { className: classes, ref: this.setWrapperRef },
317
+ this.props.existing && arrow,
318
+ !this.props.existing && description,
319
+ display_settings
320
+ );
321
+ }
322
+ }]);
323
+
324
+ return ProductsBlockSettingsEditorDisplayOptions;
325
+ }(React.Component);
326
+
327
+ /**
328
+ * The products block when in Edit mode.
329
+ */
330
+
331
+
332
+ var ProductsBlockSettingsEditor = function (_React$Component3) {
333
+ _inherits(ProductsBlockSettingsEditor, _React$Component3);
334
+
335
+ /**
336
+ * Constructor.
337
+ */
338
+ function ProductsBlockSettingsEditor(props) {
339
+ _classCallCheck(this, ProductsBlockSettingsEditor);
340
+
341
+ var _this4 = _possibleConstructorReturn(this, (ProductsBlockSettingsEditor.__proto__ || Object.getPrototypeOf(ProductsBlockSettingsEditor)).call(this, props));
342
+
343
+ _this4.state = {
344
+ display: props.selected_display,
345
+ menu_visible: props.selected_display ? false : true,
346
+ expanded_group: ''
347
+ };
348
+
349
+ _this4.updateDisplay = _this4.updateDisplay.bind(_this4);
350
+ _this4.closeMenu = _this4.closeMenu.bind(_this4);
351
+ return _this4;
352
+ }
353
+
354
+ /**
355
+ * Update the display settings for the block.
356
+ *
357
+ * @param value String
358
+ */
359
+
360
+
361
+ _createClass(ProductsBlockSettingsEditor, [{
362
+ key: 'updateDisplay',
363
+ value: function updateDisplay(value) {
364
+
365
+ // If not a group update display.
366
+ var new_state = {
367
+ display: value,
368
+ menu_visible: false,
369
+ expanded_group: ''
370
+ };
371
+
372
+ var is_group = 'undefined' !== PRODUCTS_BLOCK_DISPLAY_SETTINGS[value].group_container && PRODUCTS_BLOCK_DISPLAY_SETTINGS[value].group_container;
373
+
374
+ if (is_group) {
375
+ // If the group has not been expanded, expand it.
376
+ new_state = {
377
+ menu_visible: true,
378
+ expanded_group: value
379
+
380
+ // If the group has already been expanded, collapse it.
381
+ };if (this.state.expanded_group === PRODUCTS_BLOCK_DISPLAY_SETTINGS[value].group_container) {
382
+ new_state.expanded_group = '';
383
+ }
384
+ }
385
+
386
+ this.setState(new_state);
387
+
388
+ // Only update the display setting if a non-group setting was selected.
389
+ if (!is_group) {
390
+ this.props.update_display_callback(value);
391
+ }
392
+ }
393
+ }, {
394
+ key: 'closeMenu',
395
+ value: function closeMenu() {
396
+ this.setState({
397
+ menu_visible: false
398
+ });
399
+ }
400
+
401
+ /**
402
+ * Render the display settings dropdown and any extra contextual settings.
403
+ */
404
+
405
+ }, {
406
+ key: 'render',
407
+ value: function render() {
408
+ var _this5 = this;
409
+
410
+ var extra_settings = null;
411
+ if ('specific' === this.state.display) {
412
+ extra_settings = wp.element.createElement(_specificSelect.ProductsSpecificSelect, this.props);
413
+ } else if ('category' === this.state.display) {
414
+ extra_settings = wp.element.createElement(_categorySelect.ProductsCategorySelect, this.props);
415
+ } else if ('attribute' === this.state.display) {
416
+ extra_settings = wp.element.createElement(_attributeSelect.ProductsAttributeSelect, this.props);
417
+ }
418
+
419
+ var menu = this.state.menu_visible ? wp.element.createElement(ProductsBlockSettingsEditorDisplayOptions, { extended: this.state.expanded_group ? true : false, existing: this.state.display ? true : false, current: this.state.display, closeMenu: this.closeMenu, update_display_callback: this.updateDisplay }) : null;
420
+
421
+ var heading = null;
422
+ if (this.state.display) {
423
+ var group_options = ['featured', 'on_sale', 'attribute'];
424
+ var should_group_expand = group_options.includes(this.state.display) ? this.state.display : '';
425
+ var menu_link = wp.element.createElement(
426
+ 'button',
427
+ { type: 'button', className: 'wc-products-settings-heading__change-button button-link', onClick: function onClick() {
428
+ _this5.setState({ menu_visible: !_this5.state.menu_visible, expanded_group: should_group_expand });
429
+ } },
430
+ __('Display different products')
431
+ );
432
+
433
+ heading = wp.element.createElement(
434
+ 'div',
435
+ { className: 'wc-products-settings-heading' },
436
+ wp.element.createElement(
437
+ 'div',
438
+ { className: 'wc-products-settings-heading__current' },
439
+ __('Displaying '),
440
+ wp.element.createElement(
441
+ 'strong',
442
+ null,
443
+ __(PRODUCTS_BLOCK_DISPLAY_SETTINGS[this.state.display].title)
444
+ )
445
+ ),
446
+ wp.element.createElement(
447
+ 'div',
448
+ { className: 'wc-products-settings-heading__change' },
449
+ menu_link
450
+ )
451
+ );
452
+ }
453
+
454
+ var done_button = wp.element.createElement(
455
+ 'button',
456
+ { type: 'button', className: 'button wc-products-settings__footer-button', onClick: this.props.done_callback },
457
+ __('Done')
458
+ );
459
+ if (['', 'specific', 'category', 'attribute'].includes(this.state.display) && !this.props.selected_display_setting.length) {
460
+ var done_tooltips = {
461
+ '': __('Please select which products you\'d like to display'),
462
+ specific: __('Please search for and select products to display'),
463
+ category: __('Please select at least one category to display'),
464
+ attribute: __('Please select an attribute')
465
+ };
466
+
467
+ done_button = wp.element.createElement(
468
+ Tooltip,
469
+ { text: done_tooltips[this.state.display] },
470
+ wp.element.createElement(
471
+ 'button',
472
+ { type: 'button', className: 'button wc-products-settings__footer-button disabled' },
473
+ __('Done')
474
+ )
475
+ );
476
+ }
477
+
478
+ return wp.element.createElement(
479
+ 'div',
480
+ { className: 'wc-products-settings ' + (this.state.expanded_group ? 'expanded-group-' + this.state.expanded_group : '') },
481
+ wp.element.createElement(
482
+ 'h4',
483
+ { className: 'wc-products-settings__title' },
484
+ wp.element.createElement(Dashicon, { icon: 'screenoptions' }),
485
+ ' ',
486
+ __('Products')
487
+ ),
488
+ heading,
489
+ menu,
490
+ extra_settings,
491
+ wp.element.createElement(
492
+ 'div',
493
+ { className: 'wc-products-settings__footer' },
494
+ done_button
495
+ )
496
+ );
497
+ }
498
+ }]);
499
+
500
+ return ProductsBlockSettingsEditor;
501
+ }(React.Component);
502
+
503
+ /**
504
+ * One product in the product block preview.
505
+ */
506
+
507
+
508
+ var ProductPreview = function (_React$Component4) {
509
+ _inherits(ProductPreview, _React$Component4);
510
+
511
+ function ProductPreview() {
512
+ _classCallCheck(this, ProductPreview);
513
+
514
+ return _possibleConstructorReturn(this, (ProductPreview.__proto__ || Object.getPrototypeOf(ProductPreview)).apply(this, arguments));
515
+ }
516
+
517
+ _createClass(ProductPreview, [{
518
+ key: 'render',
519
+ value: function render() {
520
+ var _props = this.props,
521
+ attributes = _props.attributes,
522
+ product = _props.product;
523
+
524
+
525
+ var image = null;
526
+ if (product.images.length) {
527
+ image = wp.element.createElement('img', { src: product.images[0].src });
528
+ }
529
+
530
+ return wp.element.createElement(
531
+ 'div',
532
+ { className: 'product-preview' },
533
+ image,
534
+ wp.element.createElement(
535
+ 'div',
536
+ { className: 'product-title' },
537
+ product.name
538
+ ),
539
+ wp.element.createElement('div', { className: 'product-price', dangerouslySetInnerHTML: { __html: product.price_html } }),
540
+ wp.element.createElement(
541
+ 'span',
542
+ { className: 'product-add-to-cart' },
543
+ __('Add to cart')
544
+ )
545
+ );
546
+ }
547
+ }]);
548
+
549
+ return ProductPreview;
550
+ }(React.Component);
551
+
552
+ /**
553
+ * Renders a preview of what the block will look like with current settings.
554
+ */
555
+
556
+
557
+ var ProductsBlockPreview = withAPIData(function (_ref) {
558
+ var attributes = _ref.attributes;
559
+ var columns = attributes.columns,
560
+ rows = attributes.rows,
561
+ display = attributes.display,
562
+ display_setting = attributes.display_setting,
563
+ orderby = attributes.orderby;
564
+
565
+
566
+ var query = {
567
+ per_page: rows * columns
568
+ };
569
+
570
+ if ('specific' === display) {
571
+ query.include = display_setting.join(',');
572
+ query.per_page = display_setting.length;
573
+ } else if ('category' === display) {
574
+ query.category = display_setting.join(',');
575
+ } else if ('attribute' === display && display_setting.length) {
576
+ query.attribute = (0, _attributeSelect.getAttributeSlug)(display_setting[0]);
577
+
578
+ if (display_setting.length > 1) {
579
+ query.attribute_term = display_setting.slice(1).join(',');
580
+ }
581
+ } else if ('featured' === display) {
582
+ query.featured = 1;
583
+ } else if ('on_sale' === display) {
584
+ query.on_sale = 1;
585
+ }
586
+
587
+ // @todo Add support for orderby by sales, rating, and price to the API.
588
+ if ('title' === orderby || 'date' === orderby) {
589
+ query.orderby = orderby;
590
+
591
+ if ('title' === orderby) {
592
+ query.order = 'asc';
593
+ }
594
+ }
595
+
596
+ var query_string = '?';
597
+ var _iteratorNormalCompletion = true;
598
+ var _didIteratorError = false;
599
+ var _iteratorError = undefined;
600
+
601
+ try {
602
+ for (var _iterator = Object.keys(query)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
603
+ var key = _step.value;
604
+
605
+ query_string += key + '=' + query[key] + '&';
606
+ }
607
+ } catch (err) {
608
+ _didIteratorError = true;
609
+ _iteratorError = err;
610
+ } finally {
611
+ try {
612
+ if (!_iteratorNormalCompletion && _iterator.return) {
613
+ _iterator.return();
614
+ }
615
+ } finally {
616
+ if (_didIteratorError) {
617
+ throw _iteratorError;
618
+ }
619
+ }
620
+ }
621
+
622
+ return {
623
+ products: '/wc/v2/products' + query_string
624
+ };
625
+ })(function (_ref2) {
626
+ var products = _ref2.products,
627
+ attributes = _ref2.attributes;
628
+
629
+
630
+ if (!products.data) {
631
+ return __('Loading');
632
+ }
633
+
634
+ if (0 === products.data.length) {
635
+ return __('No products found');
636
+ }
637
+
638
+ var classes = "wc-products-block-preview cols-" + attributes.columns;
639
+
640
+ return wp.element.createElement(
641
+ 'div',
642
+ { className: classes },
643
+ products.data.map(function (product) {
644
+ return wp.element.createElement(ProductPreview, { key: product.id, product: product, attributes: attributes });
645
+ })
646
+ );
647
+ });
648
+
649
+ /**
650
+ * Information about current block settings rendered in the sidebar.
651
+ */
652
+ var ProductsBlockSidebarInfo = withAPIData(function (_ref3) {
653
+ var attributes = _ref3.attributes;
654
+ var display = attributes.display,
655
+ display_setting = attributes.display_setting;
656
+
657
+
658
+ if ('attribute' === display && display_setting.length) {
659
+ var ID = (0, _attributeSelect.getAttributeID)(display_setting[0]);
660
+ var terms = display_setting.slice(1).join(', ');
661
+ var endpoints = {
662
+ attributeInfo: '/wc/v2/products/attributes/' + ID
663
+ };
664
+
665
+ if (terms.length) {
666
+ endpoints.termInfo = '/wc/v2/products/attributes/' + ID + '/terms?include=' + terms;
667
+ }
668
+
669
+ return endpoints;
670
+ } else if ('category' === display && display_setting.length) {
671
+ return {
672
+ categoriesInfo: '/wc/v2/products/categories?include=' + display_setting.join(',')
673
+ };
674
+ }
675
+
676
+ return {};
677
+ })(function (_ref4) {
678
+ var attributes = _ref4.attributes,
679
+ categoriesInfo = _ref4.categoriesInfo,
680
+ attributeInfo = _ref4.attributeInfo,
681
+ termInfo = _ref4.termInfo;
682
+
683
+
684
+ var descriptions = [
685
+ // Standard description of selected scope.
686
+ PRODUCTS_BLOCK_DISPLAY_SETTINGS[attributes.display].title];
687
+
688
+ // Description of categories selected scope.
689
+ if (categoriesInfo && categoriesInfo.data && categoriesInfo.data.length) {
690
+ var descriptionText = __('Product categories: ');
691
+ var categories = [];
692
+ var _iteratorNormalCompletion2 = true;
693
+ var _didIteratorError2 = false;
694
+ var _iteratorError2 = undefined;
695
+
696
+ try {
697
+ for (var _iterator2 = categoriesInfo.data[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
698
+ var category = _step2.value;
699
+
700
+ categories.push(category.name);
701
+ }
702
+ } catch (err) {
703
+ _didIteratorError2 = true;
704
+ _iteratorError2 = err;
705
+ } finally {
706
+ try {
707
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
708
+ _iterator2.return();
709
+ }
710
+ } finally {
711
+ if (_didIteratorError2) {
712
+ throw _iteratorError2;
713
+ }
714
+ }
715
+ }
716
+
717
+ descriptionText += categories.join(', ');
718
+
719
+ descriptions = [descriptionText];
720
+
721
+ // Description of attributes selected scope.
722
+ } else if (attributeInfo && attributeInfo.data) {
723
+ descriptions = [__('Attribute: ') + attributeInfo.data.name];
724
+
725
+ if (termInfo && termInfo.data && termInfo.data.length) {
726
+ var termDescriptionText = __("Terms: ");
727
+ var terms = [];
728
+ var _iteratorNormalCompletion3 = true;
729
+ var _didIteratorError3 = false;
730
+ var _iteratorError3 = undefined;
731
+
732
+ try {
733
+ for (var _iterator3 = termInfo.data[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
734
+ var term = _step3.value;
735
+
736
+ terms.push(term.name);
737
+ }
738
+ } catch (err) {
739
+ _didIteratorError3 = true;
740
+ _iteratorError3 = err;
741
+ } finally {
742
+ try {
743
+ if (!_iteratorNormalCompletion3 && _iterator3.return) {
744
+ _iterator3.return();
745
+ }
746
+ } finally {
747
+ if (_didIteratorError3) {
748
+ throw _iteratorError3;
749
+ }
750
+ }
751
+ }
752
+
753
+ termDescriptionText += terms.join(', ');
754
+ descriptions.push(termDescriptionText);
755
+ }
756
+ }
757
+
758
+ return wp.element.createElement(
759
+ 'div',
760
+ null,
761
+ descriptions.map(function (description) {
762
+ return wp.element.createElement(
763
+ 'div',
764
+ { className: 'scope-description' },
765
+ description
766
+ );
767
+ })
768
+ );
769
+ });
770
+
771
+ /**
772
+ * The main products block UI.
773
+ */
774
+
775
+ var ProductsBlock = function (_React$Component5) {
776
+ _inherits(ProductsBlock, _React$Component5);
777
+
778
+ /**
779
+ * Constructor.
780
+ */
781
+ function ProductsBlock(props) {
782
+ _classCallCheck(this, ProductsBlock);
783
+
784
+ var _this7 = _possibleConstructorReturn(this, (ProductsBlock.__proto__ || Object.getPrototypeOf(ProductsBlock)).call(this, props));
785
+
786
+ _this7.getInspectorControls = _this7.getInspectorControls.bind(_this7);
787
+ _this7.getToolbarControls = _this7.getToolbarControls.bind(_this7);
788
+ _this7.getBlockDescription = _this7.getBlockDescription.bind(_this7);
789
+ _this7.getPreview = _this7.getPreview.bind(_this7);
790
+ _this7.getSettingsEditor = _this7.getSettingsEditor.bind(_this7);
791
+ return _this7;
792
+ }
793
+
794
+ /**
795
+ * Get the components for the sidebar settings area that is rendered while focused on a Products block.
796
+ *
797
+ * @return Component
798
+ */
799
+
800
+
801
+ _createClass(ProductsBlock, [{
802
+ key: 'getInspectorControls',
803
+ value: function getInspectorControls() {
804
+ var _props2 = this.props,
805
+ attributes = _props2.attributes,
806
+ setAttributes = _props2.setAttributes;
807
+ var rows = attributes.rows,
808
+ columns = attributes.columns,
809
+ display = attributes.display,
810
+ display_setting = attributes.display_setting,
811
+ orderby = attributes.orderby,
812
+ edit_mode = attributes.edit_mode;
813
+
814
+
815
+ var columnControl = wp.element.createElement(RangeControl, {
816
+ label: __('Columns'),
817
+ value: columns,
818
+ onChange: function onChange(value) {
819
+ return setAttributes({ columns: value });
820
+ },
821
+ min: wc_product_block_data.min_columns,
822
+ max: wc_product_block_data.max_columns
823
+ });
824
+
825
+ var orderControl = wp.element.createElement(SelectControl, {
826
+ key: 'query-panel-select',
827
+ label: __('Order Products By'),
828
+ value: orderby,
829
+ options: [{
830
+ label: __('Newness - newest first'),
831
+ value: 'date'
832
+ }, {
833
+ label: __('Price - low to high'),
834
+ value: 'price_asc'
835
+ }, {
836
+ label: __('Price - high to low'),
837
+ value: 'price_desc'
838
+ }, {
839
+ label: __('Rating - highest first'),
840
+ value: 'rating'
841
+ }, {
842
+ label: __('Sales - most first'),
843
+ value: 'popularity'
844
+ }, {
845
+ label: __('Title - alphabetical'),
846
+ value: 'title'
847
+ }],
848
+ onChange: function onChange(value) {
849
+ return setAttributes({ orderby: value });
850
+ }
851
+ });
852
+
853
+ // Row settings don't make sense for specific-selected products display.
854
+ var rowControl = null;
855
+ if ('specific' !== display) {
856
+ rowControl = wp.element.createElement(RangeControl, {
857
+ label: __('Rows'),
858
+ value: rows,
859
+ onChange: function onChange(value) {
860
+ return setAttributes({ rows: value });
861
+ },
862
+ min: wc_product_block_data.min_rows,
863
+ max: wc_product_block_data.max_rows
864
+ });
865
+ }
866
+
867
+ return wp.element.createElement(
868
+ InspectorControls,
869
+ { key: 'inspector' },
870
+ this.getBlockDescription(),
871
+ wp.element.createElement(
872
+ 'h3',
873
+ null,
874
+ __('Layout')
875
+ ),
876
+ columnControl,
877
+ rowControl,
878
+ orderControl
879
+ );
880
+ }
881
+
882
+ /**
883
+ * Get the components for the toolbar area that appears on top of the block when focused.
884
+ *
885
+ * @return Component
886
+ */
887
+
888
+ }, {
889
+ key: 'getToolbarControls',
890
+ value: function getToolbarControls() {
891
+ var props = this.props;
892
+ var attributes = props.attributes,
893
+ setAttributes = props.setAttributes;
894
+ var display = attributes.display,
895
+ display_setting = attributes.display_setting,
896
+ edit_mode = attributes.edit_mode;
897
+
898
+ // Edit button should not do anything if valid product selection has not been made.
899
+
900
+ var shouldDisableEditButton = ['', 'specific', 'category', 'attribute'].includes(display) && !display_setting.length;
901
+
902
+ var editButton = [{
903
+ icon: 'edit',
904
+ title: __('Edit'),
905
+ onClick: shouldDisableEditButton ? function () {} : function () {
906
+ return setAttributes({ edit_mode: !edit_mode });
907
+ },
908
+ isActive: edit_mode
909
+ }];
910
+
911
+ return wp.element.createElement(
912
+ BlockControls,
913
+ { key: 'controls' },
914
+ wp.element.createElement(Toolbar, { controls: editButton })
915
+ );
916
+ }
917
+
918
+ /**
919
+ * Get a description of the current block settings.
920
+ *
921
+ * @return Component
922
+ */
923
+
924
+ }, {
925
+ key: 'getBlockDescription',
926
+ value: function getBlockDescription() {
927
+ var _props3 = this.props,
928
+ attributes = _props3.attributes,
929
+ setAttributes = _props3.setAttributes;
930
+ var display = attributes.display,
931
+ display_setting = attributes.display_setting,
932
+ edit_mode = attributes.edit_mode;
933
+
934
+
935
+ if (!display.length) {
936
+ return null;
937
+ }
938
+
939
+ function editQuicklinkHandler() {
940
+ setAttributes({
941
+ edit_mode: true
942
+ });
943
+
944
+ // @todo center in view
945
+ }
946
+
947
+ var editQuickLink = null;
948
+ if (!attributes.edit_mode) {
949
+ editQuickLink = wp.element.createElement(
950
+ 'div',
951
+ { className: 'wc-products-scope-description--edit-quicklink' },
952
+ wp.element.createElement(
953
+ 'a',
954
+ { onClick: editQuicklinkHandler },
955
+ __('Edit')
956
+ )
957
+ );
958
+ }
959
+
960
+ return wp.element.createElement(
961
+ 'div',
962
+ { className: 'wc-products-scope-descriptions' },
963
+ wp.element.createElement(
964
+ 'div',
965
+ { className: 'wc-products-scope-details' },
966
+ wp.element.createElement(
967
+ 'h3',
968
+ null,
969
+ __('Current Source')
970
+ ),
971
+ wp.element.createElement(ProductsBlockSidebarInfo, { attributes: attributes })
972
+ ),
973
+ editQuickLink
974
+ );
975
+ }
976
+
977
+ /**
978
+ * Get the block preview component for preview mode.
979
+ *
980
+ * @return Component
981
+ */
982
+
983
+ }, {
984
+ key: 'getPreview',
985
+ value: function getPreview() {
986
+ return wp.element.createElement(ProductsBlockPreview, { attributes: this.props.attributes });
987
+ }
988
+
989
+ /**
990
+ * Get the block edit component for edit mode.
991
+ *
992
+ * @return Component
993
+ */
994
+
995
+ }, {
996
+ key: 'getSettingsEditor',
997
+ value: function getSettingsEditor() {
998
+ var _props4 = this.props,
999
+ attributes = _props4.attributes,
1000
+ setAttributes = _props4.setAttributes;
1001
+ var display = attributes.display,
1002
+ display_setting = attributes.display_setting;
1003
+
1004
+
1005
+ var update_display_callback = function update_display_callback(value) {
1006
+
1007
+ // These options have setting screens that need further input from the user, so keep edit mode open.
1008
+ var needsFurtherSettings = ['specific', 'attribute', 'category'];
1009
+
1010
+ if (display !== value) {
1011
+ setAttributes({
1012
+ display: value,
1013
+ display_setting: [],
1014
+ edit_mode: needsFurtherSettings.includes(value)
1015
+ });
1016
+ }
1017
+ };
1018
+
1019
+ return wp.element.createElement(ProductsBlockSettingsEditor, {
1020
+ attributes: attributes,
1021
+ selected_display: display,
1022
+ selected_display_setting: display_setting,
1023
+ update_display_callback: update_display_callback,
1024
+ update_display_setting_callback: function update_display_setting_callback(value) {
1025
+ return setAttributes({ display_setting: value });
1026
+ },
1027
+ done_callback: function done_callback() {
1028
+ return setAttributes({ edit_mode: false });
1029
+ }
1030
+ });
1031
+ }
1032
+ }, {
1033
+ key: 'render',
1034
+ value: function render() {
1035
+ var _props5 = this.props,
1036
+ attributes = _props5.attributes,
1037
+ focus = _props5.focus;
1038
+ var edit_mode = attributes.edit_mode;
1039
+
1040
+
1041
+ return [!!focus ? this.getInspectorControls() : null, !!focus ? this.getToolbarControls() : null, edit_mode ? this.getSettingsEditor() : this.getPreview()];
1042
+ }
1043
+ }]);
1044
+
1045
+ return ProductsBlock;
1046
+ }(React.Component);
1047
+
1048
+ /**
1049
+ * Register and run the products block.
1050
+ */
1051
+
1052
+
1053
+ registerBlockType('woocommerce/products', {
1054
+ title: __('Products'),
1055
+ icon: 'screenoptions',
1056
+ category: 'widgets',
1057
+ description: __('Display a grid of products from a variety of sources.'),
1058
+
1059
+ attributes: {
1060
+
1061
+ /**
1062
+ * Number of columns.
1063
+ */
1064
+ columns: {
1065
+ type: 'number',
1066
+ default: wc_product_block_data.default_columns
1067
+ },
1068
+
1069
+ /**
1070
+ * Number of rows.
1071
+ */
1072
+ rows: {
1073
+ type: 'number',
1074
+ default: wc_product_block_data.default_rows
1075
+ },
1076
+
1077
+ /**
1078
+ * What types of products to display. 'all', 'specific', or 'category'.
1079
+ */
1080
+ display: {
1081
+ type: 'string',
1082
+ default: ''
1083
+ },
1084
+
1085
+ /**
1086
+ * Which products to display if 'display' is 'specific' or 'category'. Array of product ids or category slugs depending on setting.
1087
+ */
1088
+ display_setting: {
1089
+ type: 'array',
1090
+ default: []
1091
+ },
1092
+
1093
+ /**
1094
+ * How to order the products: 'date', 'popularity', 'price_asc', 'price_desc' 'rating', 'title'.
1095
+ */
1096
+ orderby: {
1097
+ type: 'string',
1098
+ default: 'date'
1099
+ },
1100
+
1101
+ /**
1102
+ * Whether the block is in edit or preview mode.
1103
+ */
1104
+ edit_mode: {
1105
+ type: 'boolean',
1106
+ default: true
1107
+ }
1108
+ },
1109
+
1110
+ /**
1111
+ * Renders and manages the block.
1112
+ */
1113
+ edit: function edit(props) {
1114
+ return wp.element.createElement(ProductsBlock, props);
1115
+ },
1116
+
1117
+
1118
+ /**
1119
+ * Save the block content in the post content. Block content is saved as a products shortcode.
1120
+ *
1121
+ * @return string
1122
+ */
1123
+ save: function save(props) {
1124
+ var _props$attributes = props.attributes,
1125
+ rows = _props$attributes.rows,
1126
+ columns = _props$attributes.columns,
1127
+ display = _props$attributes.display,
1128
+ display_setting = _props$attributes.display_setting,
1129
+ orderby = _props$attributes.orderby;
1130
+
1131
+
1132
+ var shortcode_atts = new Map();
1133
+ if ('specific' !== display) {
1134
+ shortcode_atts.set('limit', rows * columns);
1135
+ }
1136
+ shortcode_atts.set('columns', columns);
1137
+
1138
+ if ('specific' === display) {
1139
+ shortcode_atts.set('ids', display_setting.join(','));
1140
+ } else if ('category' === display) {
1141
+ shortcode_atts.set('category', display_setting.join(','));
1142
+ } else if ('featured' === display) {
1143
+ shortcode_atts.set('visibility', 'featured');
1144
+ } else if ('on_sale' === display) {
1145
+ shortcode_atts.set('on_sale', '1');
1146
+ } else if ('attribute' === display) {
1147
+ var attribute = display_setting.length ? (0, _attributeSelect.getAttributeSlug)(display_setting[0]) : '';
1148
+ var terms = display_setting.length > 1 ? display_setting.slice(1).join(',') : '';
1149
+
1150
+ shortcode_atts.set('attribute', attribute);
1151
+ if (terms.length) {
1152
+ shortcode_atts.set('terms', terms);
1153
+ }
1154
+ }
1155
+
1156
+ if ('specific' !== display) {
1157
+ if ('price_desc' === orderby) {
1158
+ shortcode_atts.set('orderby', 'price');
1159
+ shortcode_atts.set('order', 'DESC');
1160
+ } else if ('price_asc' === orderby) {
1161
+ shortcode_atts.set('orderby', 'price');
1162
+ shortcode_atts.set('order', 'ASC');
1163
+ } else {
1164
+ shortcode_atts.set('orderby', orderby);
1165
+ }
1166
+ }
1167
+
1168
+ // Build the shortcode string out of the set shortcode attributes.
1169
+ var shortcode = '[products';
1170
+ var _iteratorNormalCompletion4 = true;
1171
+ var _didIteratorError4 = false;
1172
+ var _iteratorError4 = undefined;
1173
+
1174
+ try {
1175
+ for (var _iterator4 = shortcode_atts[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
1176
+ var _ref5 = _step4.value;
1177
+
1178
+ var _ref6 = _slicedToArray(_ref5, 2);
1179
+
1180
+ var key = _ref6[0];
1181
+ var value = _ref6[1];
1182
+
1183
+ shortcode += ' ' + key + '="' + value + '"';
1184
+ }
1185
+ } catch (err) {
1186
+ _didIteratorError4 = true;
1187
+ _iteratorError4 = err;
1188
+ } finally {
1189
+ try {
1190
+ if (!_iteratorNormalCompletion4 && _iterator4.return) {
1191
+ _iterator4.return();
1192
+ }
1193
+ } finally {
1194
+ if (_didIteratorError4) {
1195
+ throw _iteratorError4;
1196
+ }
1197
+ }
1198
+ }
1199
+
1200
+ shortcode += ']';
1201
+
1202
+ return wp.element.createElement(
1203
+ RawHTML,
1204
+ null,
1205
+ shortcode
1206
+ );
1207
+ }
1208
+ });
1209
+
1210
+ /***/ }),
1211
+ /* 1 */
1212
+ /***/ (function(module, exports, __webpack_require__) {
1213
+
1214
+ "use strict";
1215
+
1216
+
1217
+ Object.defineProperty(exports, "__esModule", {
1218
+ value: true
1219
+ });
1220
+
1221
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1222
+
1223
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1224
+
1225
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
1226
+
1227
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
1228
+
1229
+ var __ = wp.i18n.__;
1230
+ var _wp$components = wp.components,
1231
+ Toolbar = _wp$components.Toolbar,
1232
+ withAPIData = _wp$components.withAPIData,
1233
+ Dropdown = _wp$components.Dropdown,
1234
+ Dashicon = _wp$components.Dashicon;
1235
+
1236
+ /**
1237
+ * Product data cache.
1238
+ * Reduces the number of API calls and makes UI smoother and faster.
1239
+ */
1240
+
1241
+ var PRODUCT_DATA = {};
1242
+
1243
+ /**
1244
+ * When the display mode is 'Specific products' search for and add products to the block.
1245
+ *
1246
+ * @todo Add the functionality and everything.
1247
+ */
1248
+
1249
+ var ProductsSpecificSelect = exports.ProductsSpecificSelect = function (_React$Component) {
1250
+ _inherits(ProductsSpecificSelect, _React$Component);
1251
+
1252
+ /**
1253
+ * Constructor.
1254
+ */
1255
+ function ProductsSpecificSelect(props) {
1256
+ _classCallCheck(this, ProductsSpecificSelect);
1257
+
1258
+ var _this = _possibleConstructorReturn(this, (ProductsSpecificSelect.__proto__ || Object.getPrototypeOf(ProductsSpecificSelect)).call(this, props));
1259
+
1260
+ _this.state = {
1261
+ selectedProducts: props.selected_display_setting || []
1262
+ };
1263
+ return _this;
1264
+ }
1265
+
1266
+ /**
1267
+ * Add a product to the list of selected products.
1268
+ *
1269
+ * @param id int Product ID.
1270
+ */
1271
+
1272
+
1273
+ _createClass(ProductsSpecificSelect, [{
1274
+ key: 'addOrRemoveProduct',
1275
+ value: function addOrRemoveProduct(id) {
1276
+ var selectedProducts = this.state.selectedProducts;
1277
+
1278
+ if (!selectedProducts.includes(id)) {
1279
+ selectedProducts.push(id);
1280
+ } else {
1281
+ selectedProducts = selectedProducts.filter(function (product) {
1282
+ return product !== id;
1283
+ });
1284
+ }
1285
+
1286
+ this.setState({
1287
+ selectedProducts: selectedProducts
1288
+ });
1289
+
1290
+ /**
1291
+ * We need to copy the existing data into a new array.
1292
+ * We can't just push the new product onto the end of the existing array because Gutenberg seems
1293
+ * to do some sort of check by reference to determine whether to *actually* update the attribute
1294
+ * and will not update it if we just pass back the same array with an extra element on the end.
1295
+ */
1296
+ this.props.update_display_setting_callback(selectedProducts.slice());
1297
+ }
1298
+
1299
+ /**
1300
+ * Render the product specific select screen.
1301
+ */
1302
+
1303
+ }, {
1304
+ key: 'render',
1305
+ value: function render() {
1306
+ return wp.element.createElement(
1307
+ 'div',
1308
+ { className: 'wc-products-list-card wc-products-list-card--specific' },
1309
+ wp.element.createElement(ProductsSpecificSearchField, {
1310
+ addOrRemoveProductCallback: this.addOrRemoveProduct.bind(this),
1311
+ selectedProducts: this.state.selectedProducts
1312
+ }),
1313
+ wp.element.createElement(ProductSpecificSelectedProducts, {
1314
+ columns: this.props.attributes.columns,
1315
+ productIds: this.state.selectedProducts,
1316
+ addOrRemoveProduct: this.addOrRemoveProduct.bind(this)
1317
+ })
1318
+ );
1319
+ }
1320
+ }]);
1321
+
1322
+ return ProductsSpecificSelect;
1323
+ }(React.Component);
1324
+
1325
+ /**
1326
+ * Product search area
1327
+ */
1328
+
1329
+
1330
+ var ProductsSpecificSearchField = function (_React$Component2) {
1331
+ _inherits(ProductsSpecificSearchField, _React$Component2);
1332
+
1333
+ /**
1334
+ * Constructor.
1335
+ */
1336
+ function ProductsSpecificSearchField(props) {
1337
+ _classCallCheck(this, ProductsSpecificSearchField);
1338
+
1339
+ var _this2 = _possibleConstructorReturn(this, (ProductsSpecificSearchField.__proto__ || Object.getPrototypeOf(ProductsSpecificSearchField)).call(this, props));
1340
+
1341
+ _this2.state = {
1342
+ searchText: '',
1343
+ dropdownOpen: false
1344
+ };
1345
+
1346
+ _this2.updateSearchResults = _this2.updateSearchResults.bind(_this2);
1347
+ _this2.setWrapperRef = _this2.setWrapperRef.bind(_this2);
1348
+ _this2.handleClickOutside = _this2.handleClickOutside.bind(_this2);
1349
+ _this2.isDropdownOpen = _this2.isDropdownOpen.bind(_this2);
1350
+ return _this2;
1351
+ }
1352
+
1353
+ /**
1354
+ * Hook in the listener for closing menu when clicked outside.
1355
+ */
1356
+
1357
+
1358
+ _createClass(ProductsSpecificSearchField, [{
1359
+ key: 'componentDidMount',
1360
+ value: function componentDidMount() {
1361
+ document.addEventListener('mousedown', this.handleClickOutside);
1362
+ }
1363
+
1364
+ /**
1365
+ * Remove the listener for closing menu when clicked outside.
1366
+ */
1367
+
1368
+ }, {
1369
+ key: 'componentWillUnmount',
1370
+ value: function componentWillUnmount() {
1371
+ document.removeEventListener('mousedown', this.handleClickOutside);
1372
+ }
1373
+
1374
+ /**
1375
+ * Set the wrapper reference.
1376
+ *
1377
+ * @param node DOMNode
1378
+ */
1379
+
1380
+ }, {
1381
+ key: 'setWrapperRef',
1382
+ value: function setWrapperRef(node) {
1383
+ this.wrapperRef = node;
1384
+ }
1385
+
1386
+ /**
1387
+ * Close the menu when user clicks outside the search area.
1388
+ */
1389
+
1390
+ }, {
1391
+ key: 'handleClickOutside',
1392
+ value: function handleClickOutside(evt) {
1393
+ if (this.wrapperRef && !this.wrapperRef.contains(event.target)) {
1394
+ this.setState({
1395
+ searchText: ''
1396
+ });
1397
+ }
1398
+ }
1399
+ }, {
1400
+ key: 'isDropdownOpen',
1401
+ value: function isDropdownOpen(isOpen) {
1402
+ this.setState({
1403
+ dropdownOpen: !!isOpen
1404
+ });
1405
+ }
1406
+
1407
+ /**
1408
+ * Event handler for updating results when text is typed into the input.
1409
+ *
1410
+ * @param evt Event object.
1411
+ */
1412
+
1413
+ }, {
1414
+ key: 'updateSearchResults',
1415
+ value: function updateSearchResults(evt) {
1416
+ this.setState({
1417
+ searchText: evt.target.value
1418
+ });
1419
+ }
1420
+
1421
+ /**
1422
+ * Render the product search UI.
1423
+ */
1424
+
1425
+ }, {
1426
+ key: 'render',
1427
+ value: function render() {
1428
+ var divClass = 'wc-products-list-card__search-wrapper';
1429
+
1430
+ return wp.element.createElement(
1431
+ 'div',
1432
+ { className: divClass + (this.state.dropdownOpen ? ' ' + divClass + '--with-results' : ''), ref: this.setWrapperRef },
1433
+ wp.element.createElement(
1434
+ 'div',
1435
+ { className: 'wc-products-list-card__input-wrapper' },
1436
+ wp.element.createElement(Dashicon, { icon: 'search' }),
1437
+ wp.element.createElement('input', { type: 'search',
1438
+ className: 'wc-products-list-card__search',
1439
+ value: this.state.searchText,
1440
+ placeholder: __('Search for products to display'),
1441
+ onChange: this.updateSearchResults
1442
+ })
1443
+ ),
1444
+ wp.element.createElement(ProductSpecificSearchResults, {
1445
+ searchString: this.state.searchText,
1446
+ addOrRemoveProductCallback: this.props.addOrRemoveProductCallback,
1447
+ selectedProducts: this.props.selectedProducts,
1448
+ isDropdownOpenCallback: this.isDropdownOpen
1449
+ })
1450
+ );
1451
+ }
1452
+ }]);
1453
+
1454
+ return ProductsSpecificSearchField;
1455
+ }(React.Component);
1456
+
1457
+ /**
1458
+ * Render product search results based on the text entered into the textbox.
1459
+ */
1460
+
1461
+
1462
+ var ProductSpecificSearchResults = withAPIData(function (props) {
1463
+
1464
+ if (!props.searchString.length) {
1465
+ return {
1466
+ products: []
1467
+ };
1468
+ }
1469
+
1470
+ return {
1471
+ products: '/wc/v2/products?per_page=10&search=' + props.searchString
1472
+ };
1473
+ })(function (_ref) {
1474
+ var products = _ref.products,
1475
+ addOrRemoveProductCallback = _ref.addOrRemoveProductCallback,
1476
+ selectedProducts = _ref.selectedProducts,
1477
+ isDropdownOpenCallback = _ref.isDropdownOpenCallback;
1478
+
1479
+ if (!products.data) {
1480
+ return null;
1481
+ }
1482
+
1483
+ if (0 === products.data.length) {
1484
+ return wp.element.createElement(
1485
+ 'span',
1486
+ { className: 'wc-products-list-card__search-no-results' },
1487
+ ' ',
1488
+ __('No products found'),
1489
+ ' '
1490
+ );
1491
+ }
1492
+
1493
+ // Populate the cache.
1494
+ var _iteratorNormalCompletion = true;
1495
+ var _didIteratorError = false;
1496
+ var _iteratorError = undefined;
1497
+
1498
+ try {
1499
+ for (var _iterator = products.data[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
1500
+ var product = _step.value;
1501
+
1502
+ PRODUCT_DATA[product.id] = product;
1503
+ }
1504
+ } catch (err) {
1505
+ _didIteratorError = true;
1506
+ _iteratorError = err;
1507
+ } finally {
1508
+ try {
1509
+ if (!_iteratorNormalCompletion && _iterator.return) {
1510
+ _iterator.return();
1511
+ }
1512
+ } finally {
1513
+ if (_didIteratorError) {
1514
+ throw _iteratorError;
1515
+ }
1516
+ }
1517
+ }
1518
+
1519
+ return wp.element.createElement(ProductSpecificSearchResultsDropdown, {
1520
+ products: products.data,
1521
+ addOrRemoveProductCallback: addOrRemoveProductCallback,
1522
+ selectedProducts: selectedProducts,
1523
+ isDropdownOpenCallback: isDropdownOpenCallback
1524
+ });
1525
+ });
1526
+
1527
+ /**
1528
+ * The dropdown of search results.
1529
+ */
1530
+
1531
+ var ProductSpecificSearchResultsDropdown = function (_React$Component3) {
1532
+ _inherits(ProductSpecificSearchResultsDropdown, _React$Component3);
1533
+
1534
+ function ProductSpecificSearchResultsDropdown() {
1535
+ _classCallCheck(this, ProductSpecificSearchResultsDropdown);
1536
+
1537
+ return _possibleConstructorReturn(this, (ProductSpecificSearchResultsDropdown.__proto__ || Object.getPrototypeOf(ProductSpecificSearchResultsDropdown)).apply(this, arguments));
1538
+ }
1539
+
1540
+ _createClass(ProductSpecificSearchResultsDropdown, [{
1541
+ key: 'componentDidMount',
1542
+
1543
+
1544
+ /**
1545
+ * Set the state of the dropdown to open.
1546
+ */
1547
+ value: function componentDidMount() {
1548
+ this.props.isDropdownOpenCallback(true);
1549
+ }
1550
+
1551
+ /**
1552
+ * Set the state of the dropdown to closed.
1553
+ */
1554
+
1555
+ }, {
1556
+ key: 'componentWillUnmount',
1557
+ value: function componentWillUnmount() {
1558
+ this.props.isDropdownOpenCallback(false);
1559
+ }
1560
+
1561
+ /**
1562
+ * Render dropdown.
1563
+ */
1564
+
1565
+ }, {
1566
+ key: 'render',
1567
+ value: function render() {
1568
+ var _props = this.props,
1569
+ products = _props.products,
1570
+ addOrRemoveProductCallback = _props.addOrRemoveProductCallback,
1571
+ selectedProducts = _props.selectedProducts;
1572
+
1573
+
1574
+ var productElements = [];
1575
+
1576
+ var _iteratorNormalCompletion2 = true;
1577
+ var _didIteratorError2 = false;
1578
+ var _iteratorError2 = undefined;
1579
+
1580
+ try {
1581
+ for (var _iterator2 = products[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
1582
+ var product = _step2.value;
1583
+
1584
+ productElements.push(wp.element.createElement(ProductSpecificSearchResultsDropdownElement, {
1585
+ product: product,
1586
+ addOrRemoveProductCallback: addOrRemoveProductCallback,
1587
+ selected: selectedProducts.includes(product.id)
1588
+ }));
1589
+ }
1590
+ } catch (err) {
1591
+ _didIteratorError2 = true;
1592
+ _iteratorError2 = err;
1593
+ } finally {
1594
+ try {
1595
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
1596
+ _iterator2.return();
1597
+ }
1598
+ } finally {
1599
+ if (_didIteratorError2) {
1600
+ throw _iteratorError2;
1601
+ }
1602
+ }
1603
+ }
1604
+
1605
+ return wp.element.createElement(
1606
+ 'div',
1607
+ { role: 'menu', className: 'wc-products-list-card__search-results', 'aria-orientation': 'vertical', 'aria-label': __('Products list') },
1608
+ wp.element.createElement(
1609
+ 'div',
1610
+ null,
1611
+ productElements
1612
+ )
1613
+ );
1614
+ }
1615
+ }]);
1616
+
1617
+ return ProductSpecificSearchResultsDropdown;
1618
+ }(React.Component);
1619
+
1620
+ /**
1621
+ * One search result.
1622
+ */
1623
+
1624
+
1625
+ var ProductSpecificSearchResultsDropdownElement = function (_React$Component4) {
1626
+ _inherits(ProductSpecificSearchResultsDropdownElement, _React$Component4);
1627
+
1628
+ /**
1629
+ * Constructor.
1630
+ */
1631
+ function ProductSpecificSearchResultsDropdownElement(props) {
1632
+ _classCallCheck(this, ProductSpecificSearchResultsDropdownElement);
1633
+
1634
+ var _this4 = _possibleConstructorReturn(this, (ProductSpecificSearchResultsDropdownElement.__proto__ || Object.getPrototypeOf(ProductSpecificSearchResultsDropdownElement)).call(this, props));
1635
+
1636
+ _this4.handleClick = _this4.handleClick.bind(_this4);
1637
+ return _this4;
1638
+ }
1639
+
1640
+ /**
1641
+ * Add product to main list and change UI to show it was added.
1642
+ */
1643
+
1644
+
1645
+ _createClass(ProductSpecificSearchResultsDropdownElement, [{
1646
+ key: 'handleClick',
1647
+ value: function handleClick() {
1648
+ this.props.addOrRemoveProductCallback(this.props.product.id);
1649
+ }
1650
+
1651
+ /**
1652
+ * Render one result in the search results.
1653
+ */
1654
+
1655
+ }, {
1656
+ key: 'render',
1657
+ value: function render() {
1658
+ var product = this.props.product;
1659
+ var icon = this.props.selected ? wp.element.createElement(Dashicon, { icon: 'yes' }) : null;
1660
+
1661
+ return wp.element.createElement(
1662
+ 'div',
1663
+ { className: 'wc-products-list-card__content' + (this.props.selected ? ' wc-products-list-card__content--added' : ''), onClick: this.handleClick },
1664
+ wp.element.createElement('img', { src: product.images[0].src }),
1665
+ wp.element.createElement(
1666
+ 'span',
1667
+ { className: 'wc-products-list-card__content-item-name' },
1668
+ product.name
1669
+ ),
1670
+ icon
1671
+ );
1672
+ }
1673
+ }]);
1674
+
1675
+ return ProductSpecificSearchResultsDropdownElement;
1676
+ }(React.Component);
1677
+
1678
+ /**
1679
+ * List preview of selected products.
1680
+ */
1681
+
1682
+
1683
+ var ProductSpecificSelectedProducts = withAPIData(function (props) {
1684
+ if (!props.productIds.length) {
1685
+ return {
1686
+ products: []
1687
+ };
1688
+ }
1689
+
1690
+ // Determine which products are not already in the cache and only fetch uncached products.
1691
+ var uncachedProducts = [];
1692
+ var _iteratorNormalCompletion3 = true;
1693
+ var _didIteratorError3 = false;
1694
+ var _iteratorError3 = undefined;
1695
+
1696
+ try {
1697
+ for (var _iterator3 = props.productIds[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
1698
+ var productId = _step3.value;
1699
+
1700
+ if (!PRODUCT_DATA.hasOwnProperty(productId)) {
1701
+ uncachedProducts.push(productId);
1702
+ }
1703
+ }
1704
+ } catch (err) {
1705
+ _didIteratorError3 = true;
1706
+ _iteratorError3 = err;
1707
+ } finally {
1708
+ try {
1709
+ if (!_iteratorNormalCompletion3 && _iterator3.return) {
1710
+ _iterator3.return();
1711
+ }
1712
+ } finally {
1713
+ if (_didIteratorError3) {
1714
+ throw _iteratorError3;
1715
+ }
1716
+ }
1717
+ }
1718
+
1719
+ return {
1720
+ products: uncachedProducts.length ? '/wc/v2/products?include=' + uncachedProducts.join(',') : []
1721
+ };
1722
+ })(function (_ref2) {
1723
+ var productIds = _ref2.productIds,
1724
+ products = _ref2.products,
1725
+ columns = _ref2.columns,
1726
+ addOrRemoveProduct = _ref2.addOrRemoveProduct;
1727
+
1728
+
1729
+ // Add new products to cache.
1730
+ if (products.data) {
1731
+ var _iteratorNormalCompletion4 = true;
1732
+ var _didIteratorError4 = false;
1733
+ var _iteratorError4 = undefined;
1734
+
1735
+ try {
1736
+ for (var _iterator4 = products.data[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
1737
+ var product = _step4.value;
1738
+
1739
+ PRODUCT_DATA[product.id] = product;
1740
+ }
1741
+ } catch (err) {
1742
+ _didIteratorError4 = true;
1743
+ _iteratorError4 = err;
1744
+ } finally {
1745
+ try {
1746
+ if (!_iteratorNormalCompletion4 && _iterator4.return) {
1747
+ _iterator4.return();
1748
+ }
1749
+ } finally {
1750
+ if (_didIteratorError4) {
1751
+ throw _iteratorError4;
1752
+ }
1753
+ }
1754
+ }
1755
+ }
1756
+
1757
+ var productElements = [];
1758
+
1759
+ var _loop = function _loop(productId) {
1760
+
1761
+ // Skip products that aren't in the cache yet or failed to fetch.
1762
+ if (!PRODUCT_DATA.hasOwnProperty(productId)) {
1763
+ return 'continue';
1764
+ }
1765
+
1766
+ var productData = PRODUCT_DATA[productId];
1767
+
1768
+ productElements.push(wp.element.createElement(
1769
+ 'li',
1770
+ { className: 'wc-products-list-card__item' },
1771
+ wp.element.createElement(
1772
+ 'div',
1773
+ { className: 'wc-products-list-card__content' },
1774
+ wp.element.createElement('img', { src: productData.images[0].src }),
1775
+ wp.element.createElement(
1776
+ 'span',
1777
+ { className: 'wc-products-list-card__content-item-name' },
1778
+ productData.name
1779
+ ),
1780
+ wp.element.createElement(
1781
+ 'button',
1782
+ {
1783
+ type: 'button',
1784
+ id: 'product-' + productData.id,
1785
+ onClick: function onClick() {
1786
+ addOrRemoveProduct(productData.id);
1787
+ } },
1788
+ wp.element.createElement(Dashicon, { icon: 'no-alt' })
1789
+ )
1790
+ )
1791
+ ));
1792
+ };
1793
+
1794
+ var _iteratorNormalCompletion5 = true;
1795
+ var _didIteratorError5 = false;
1796
+ var _iteratorError5 = undefined;
1797
+
1798
+ try {
1799
+ for (var _iterator5 = productIds[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
1800
+ var productId = _step5.value;
1801
+
1802
+ var _ret = _loop(productId);
1803
+
1804
+ if (_ret === 'continue') continue;
1805
+ }
1806
+ } catch (err) {
1807
+ _didIteratorError5 = true;
1808
+ _iteratorError5 = err;
1809
+ } finally {
1810
+ try {
1811
+ if (!_iteratorNormalCompletion5 && _iterator5.return) {
1812
+ _iterator5.return();
1813
+ }
1814
+ } finally {
1815
+ if (_didIteratorError5) {
1816
+ throw _iteratorError5;
1817
+ }
1818
+ }
1819
+ }
1820
+
1821
+ return wp.element.createElement(
1822
+ 'div',
1823
+ { className: 'wc-products-list-card__results-wrapper wc-products-list-card__results-wrapper--cols-' + columns },
1824
+ wp.element.createElement(
1825
+ 'div',
1826
+ { role: 'menu', className: 'wc-products-list-card__results', 'aria-orientation': 'vertical', 'aria-label': __('Selected products') },
1827
+ productElements.length > 0 && wp.element.createElement(
1828
+ 'h3',
1829
+ null,
1830
+ __('Selected products')
1831
+ ),
1832
+ wp.element.createElement(
1833
+ 'ul',
1834
+ null,
1835
+ productElements
1836
+ )
1837
+ )
1838
+ );
1839
+ });
1840
+
1841
+ /***/ }),
1842
+ /* 2 */
1843
+ /***/ (function(module, exports, __webpack_require__) {
1844
+
1845
+ "use strict";
1846
+
1847
+
1848
+ Object.defineProperty(exports, "__esModule", {
1849
+ value: true
1850
+ });
1851
+
1852
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1853
+
1854
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
1855
+
1856
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1857
+
1858
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
1859
+
1860
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
1861
+
1862
+ var __ = wp.i18n.__;
1863
+ var _wp$components = wp.components,
1864
+ Toolbar = _wp$components.Toolbar,
1865
+ withAPIData = _wp$components.withAPIData,
1866
+ Dropdown = _wp$components.Dropdown,
1867
+ Dashicon = _wp$components.Dashicon;
1868
+
1869
+ /**
1870
+ * When the display mode is 'Product category' search for and select product categories to pull products from.
1871
+ */
1872
+
1873
+ var ProductsCategorySelect = exports.ProductsCategorySelect = function (_React$Component) {
1874
+ _inherits(ProductsCategorySelect, _React$Component);
1875
+
1876
+ /**
1877
+ * Constructor.
1878
+ */
1879
+ function ProductsCategorySelect(props) {
1880
+ _classCallCheck(this, ProductsCategorySelect);
1881
+
1882
+ var _this = _possibleConstructorReturn(this, (ProductsCategorySelect.__proto__ || Object.getPrototypeOf(ProductsCategorySelect)).call(this, props));
1883
+
1884
+ _this.state = {
1885
+ selectedCategories: props.selected_display_setting,
1886
+ openAccordion: [],
1887
+ filterQuery: '',
1888
+ firstLoad: true
1889
+ };
1890
+
1891
+ _this.checkboxChange = _this.checkboxChange.bind(_this);
1892
+ _this.accordionToggle = _this.accordionToggle.bind(_this);
1893
+ _this.filterResults = _this.filterResults.bind(_this);
1894
+ _this.setFirstLoad = _this.setFirstLoad.bind(_this);
1895
+ return _this;
1896
+ }
1897
+
1898
+ /**
1899
+ * Handle checkbox toggle.
1900
+ *
1901
+ * @param Checked? boolean checked
1902
+ * @param Categories array categories
1903
+ */
1904
+
1905
+
1906
+ _createClass(ProductsCategorySelect, [{
1907
+ key: "checkboxChange",
1908
+ value: function checkboxChange(checked, categories) {
1909
+ var selectedCategories = this.state.selectedCategories;
1910
+
1911
+ selectedCategories = selectedCategories.filter(function (category) {
1912
+ return !categories.includes(category);
1913
+ });
1914
+
1915
+ if (checked) {
1916
+ var _selectedCategories;
1917
+
1918
+ (_selectedCategories = selectedCategories).push.apply(_selectedCategories, _toConsumableArray(categories));
1919
+ }
1920
+
1921
+ this.setState({
1922
+ selectedCategories: selectedCategories
1923
+ });
1924
+
1925
+ this.props.update_display_setting_callback(selectedCategories);
1926
+ }
1927
+
1928
+ /**
1929
+ * Handle accordion toggle.
1930
+ *
1931
+ * @param Category ID category
1932
+ */
1933
+
1934
+ }, {
1935
+ key: "accordionToggle",
1936
+ value: function accordionToggle(category) {
1937
+ var openAccordions = this.state.openAccordion;
1938
+
1939
+ if (openAccordions.includes(category)) {
1940
+ openAccordions = openAccordions.filter(function (c) {
1941
+ return c !== category;
1942
+ });
1943
+ } else {
1944
+ openAccordions.push(category);
1945
+ }
1946
+
1947
+ this.setState({
1948
+ openAccordion: openAccordions
1949
+ });
1950
+ }
1951
+
1952
+ /**
1953
+ * Filter categories.
1954
+ *
1955
+ * @param Event object evt
1956
+ */
1957
+
1958
+ }, {
1959
+ key: "filterResults",
1960
+ value: function filterResults(evt) {
1961
+ this.setState({
1962
+ filterQuery: evt.target.value
1963
+ });
1964
+ }
1965
+
1966
+ /**
1967
+ * Update firstLoad state.
1968
+ *
1969
+ * @param Booolean loaded
1970
+ */
1971
+
1972
+ }, {
1973
+ key: "setFirstLoad",
1974
+ value: function setFirstLoad(loaded) {
1975
+ this.setState({
1976
+ firstLoad: !!loaded
1977
+ });
1978
+ }
1979
+
1980
+ /**
1981
+ * Render the list of categories and the search input.
1982
+ */
1983
+
1984
+ }, {
1985
+ key: "render",
1986
+ value: function render() {
1987
+ return wp.element.createElement(
1988
+ "div",
1989
+ { className: "wc-products-list-card wc-products-list-card--taxonomy wc-products-list-card--taxonomy-category" },
1990
+ wp.element.createElement(ProductCategoryFilter, { filterResults: this.filterResults }),
1991
+ wp.element.createElement(ProductCategoryList, {
1992
+ filterQuery: this.state.filterQuery,
1993
+ selectedCategories: this.state.selectedCategories,
1994
+ checkboxChange: this.checkboxChange,
1995
+ accordionToggle: this.accordionToggle,
1996
+ openAccordion: this.state.openAccordion,
1997
+ firstLoad: this.state.firstLoad,
1998
+ setFirstLoad: this.setFirstLoad
1999
+ })
2000
+ );
2001
+ }
2002
+ }]);
2003
+
2004
+ return ProductsCategorySelect;
2005
+ }(React.Component);
2006
+
2007
+ /**
2008
+ * The category search input.
2009
+ */
2010
+
2011
+
2012
+ var ProductCategoryFilter = function ProductCategoryFilter(_ref) {
2013
+ var filterResults = _ref.filterResults;
2014
+
2015
+ return wp.element.createElement(
2016
+ "div",
2017
+ { className: "wc-products-list-card__input-wrapper" },
2018
+ wp.element.createElement(Dashicon, { icon: "search" }),
2019
+ wp.element.createElement("input", { className: "wc-products-list-card__search", type: "search", placeholder: __('Search for categories'), onChange: filterResults })
2020
+ );
2021
+ };
2022
+
2023
+ /**
2024
+ * Fetch and build a tree of product categories.
2025
+ */
2026
+ var ProductCategoryList = withAPIData(function (props) {
2027
+ return {
2028
+ categories: '/wc/v2/products/categories'
2029
+ };
2030
+ })(function (_ref2) {
2031
+ var categories = _ref2.categories,
2032
+ filterQuery = _ref2.filterQuery,
2033
+ selectedCategories = _ref2.selectedCategories,
2034
+ checkboxChange = _ref2.checkboxChange,
2035
+ accordionToggle = _ref2.accordionToggle,
2036
+ openAccordion = _ref2.openAccordion,
2037
+ firstLoad = _ref2.firstLoad,
2038
+ setFirstLoad = _ref2.setFirstLoad;
2039
+
2040
+ if (!categories.data) {
2041
+ return __('Loading');
2042
+ }
2043
+
2044
+ if (0 === categories.data.length) {
2045
+ return __('No categories found');
2046
+ }
2047
+
2048
+ var handleCategoriesToCheck = function handleCategoriesToCheck(evt, parent, categories) {
2049
+ var ids = getCategoryChildren(parent, categories).map(function (category) {
2050
+ return category.id;
2051
+ });
2052
+
2053
+ ids.push(parent.id);
2054
+
2055
+ checkboxChange(evt.target.checked, ids);
2056
+ };
2057
+
2058
+ var getCategoryChildren = function getCategoryChildren(parent, categories) {
2059
+ var children = [];
2060
+
2061
+ categories.filter(function (category) {
2062
+ return category.parent === parent.id;
2063
+ }).forEach(function (category) {
2064
+ children.push(category);
2065
+ children.push.apply(children, _toConsumableArray(getCategoryChildren(category, categories)));
2066
+ });
2067
+
2068
+ return children;
2069
+ };
2070
+
2071
+ var categoryHasChildren = function categoryHasChildren(parent, categories) {
2072
+ return !!getCategoryChildren(parent, categories).length;
2073
+ };
2074
+
2075
+ var isIndeterminate = function isIndeterminate(category, categories) {
2076
+
2077
+ // Currect category selected?
2078
+ if (selectedCategories.includes(category.id)) {
2079
+ return false;
2080
+ }
2081
+
2082
+ // Has children?
2083
+ var children = getCategoryChildren(category, categories).map(function (category) {
2084
+ return category.id;
2085
+ });
2086
+
2087
+ var _iteratorNormalCompletion = true;
2088
+ var _didIteratorError = false;
2089
+ var _iteratorError = undefined;
2090
+
2091
+ try {
2092
+ for (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
2093
+ var child = _step.value;
2094
+
2095
+ if (selectedCategories.includes(child)) {
2096
+ return true;
2097
+ }
2098
+ }
2099
+ } catch (err) {
2100
+ _didIteratorError = true;
2101
+ _iteratorError = err;
2102
+ } finally {
2103
+ try {
2104
+ if (!_iteratorNormalCompletion && _iterator.return) {
2105
+ _iterator.return();
2106
+ }
2107
+ } finally {
2108
+ if (_didIteratorError) {
2109
+ throw _iteratorError;
2110
+ }
2111
+ }
2112
+ }
2113
+
2114
+ return false;
2115
+ };
2116
+
2117
+ var AccordionButton = function AccordionButton(_ref3) {
2118
+ var category = _ref3.category,
2119
+ categories = _ref3.categories;
2120
+
2121
+ var icon = 'arrow-down-alt2';
2122
+
2123
+ if (openAccordion.includes(category.id)) {
2124
+ icon = 'arrow-up-alt2';
2125
+ }
2126
+
2127
+ var style = null;
2128
+
2129
+ if (!categoryHasChildren(category, categories)) {
2130
+ style = {
2131
+ visibility: 'hidden'
2132
+ };
2133
+ };
2134
+
2135
+ return wp.element.createElement(
2136
+ "button",
2137
+ { onClick: function onClick() {
2138
+ return accordionToggle(category.id);
2139
+ }, className: "wc-products-list-card__accordion-button", style: style, type: "button" },
2140
+ wp.element.createElement(Dashicon, { icon: icon })
2141
+ );
2142
+ };
2143
+
2144
+ var CategoryTree = function CategoryTree(_ref4) {
2145
+ var categories = _ref4.categories,
2146
+ parent = _ref4.parent;
2147
+
2148
+ var filteredCategories = categories.filter(function (category) {
2149
+ return category.parent === parent;
2150
+ });
2151
+
2152
+ if (firstLoad && selectedCategories.length > 0) {
2153
+ categoriesData.filter(function (category) {
2154
+ return category.parent === 0;
2155
+ }).forEach(function (category) {
2156
+ var children = getCategoryChildren(category, categoriesData);
2157
+
2158
+ var _iteratorNormalCompletion2 = true;
2159
+ var _didIteratorError2 = false;
2160
+ var _iteratorError2 = undefined;
2161
+
2162
+ try {
2163
+ for (var _iterator2 = children[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
2164
+ var child = _step2.value;
2165
+
2166
+ if (selectedCategories.includes(child.id) && !openAccordion.includes(category.id)) {
2167
+ accordionToggle(category.id);
2168
+ break;
2169
+ }
2170
+ }
2171
+ } catch (err) {
2172
+ _didIteratorError2 = true;
2173
+ _iteratorError2 = err;
2174
+ } finally {
2175
+ try {
2176
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
2177
+ _iterator2.return();
2178
+ }
2179
+ } finally {
2180
+ if (_didIteratorError2) {
2181
+ throw _iteratorError2;
2182
+ }
2183
+ }
2184
+ }
2185
+ });
2186
+
2187
+ setFirstLoad(false);
2188
+ }
2189
+
2190
+ return filteredCategories.length > 0 && wp.element.createElement(
2191
+ "ul",
2192
+ null,
2193
+ filteredCategories.map(function (category) {
2194
+ return wp.element.createElement(
2195
+ "li",
2196
+ { key: category.id, className: openAccordion.includes(category.id) ? 'wc-products-list-card__item wc-products-list-card__accordion-open' : 'wc-products-list-card__item' },
2197
+ wp.element.createElement(
2198
+ "label",
2199
+ { className: 0 === category.parent ? 'wc-products-list-card__content' : '', htmlFor: 'product-category-' + category.id },
2200
+ wp.element.createElement("input", { type: "checkbox",
2201
+ id: 'product-category-' + category.id,
2202
+ value: category.id,
2203
+ checked: selectedCategories.includes(category.id),
2204
+ onChange: function onChange(evt) {
2205
+ return handleCategoriesToCheck(evt, category, categories);
2206
+ },
2207
+ ref: function ref(el) {
2208
+ return el && (el.indeterminate = isIndeterminate(category, categories));
2209
+ }
2210
+ }),
2211
+ " ",
2212
+ category.name,
2213
+ 0 === category.parent && wp.element.createElement(AccordionButton, { category: category, categories: categories }),
2214
+ wp.element.createElement(
2215
+ "span",
2216
+ { className: "wc-products-list-card__taxonomy-count" },
2217
+ category.count
2218
+ )
2219
+ ),
2220
+ wp.element.createElement(CategoryTree, { categories: categories, parent: category.id })
2221
+ );
2222
+ })
2223
+ );
2224
+ };
2225
+
2226
+ var categoriesData = categories.data;
2227
+
2228
+ if ('' !== filterQuery) {
2229
+ categoriesData = categoriesData.filter(function (category) {
2230
+ return category.slug.includes(filterQuery.toLowerCase());
2231
+ });
2232
+ }
2233
+
2234
+ return wp.element.createElement(
2235
+ "div",
2236
+ { className: "wc-products-list-card__results" },
2237
+ wp.element.createElement(CategoryTree, { categories: categoriesData, parent: 0 })
2238
+ );
2239
+ });
2240
+
2241
+ /***/ }),
2242
+ /* 3 */
2243
+ /***/ (function(module, exports, __webpack_require__) {
2244
+
2245
+ "use strict";
2246
+
2247
+
2248
+ Object.defineProperty(exports, "__esModule", {
2249
+ value: true
2250
+ });
2251
+
2252
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2253
+
2254
+ exports.getAttributeIdentifier = getAttributeIdentifier;
2255
+ exports.getAttributeSlug = getAttributeSlug;
2256
+ exports.getAttributeID = getAttributeID;
2257
+
2258
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2259
+
2260
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
2261
+
2262
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
2263
+
2264
+ var __ = wp.i18n.__;
2265
+ var _wp$components = wp.components,
2266
+ Toolbar = _wp$components.Toolbar,
2267
+ withAPIData = _wp$components.withAPIData,
2268
+ Dropdown = _wp$components.Dropdown,
2269
+ Dashicon = _wp$components.Dashicon;
2270
+
2271
+ /**
2272
+ * Attribute data cache.
2273
+ * Needed because it takes a lot of API calls to generate attribute info.
2274
+ */
2275
+
2276
+ var PRODUCT_ATTRIBUTE_DATA = {};
2277
+
2278
+ /**
2279
+ * Get the identifier for an attribute. The identifier can be used to determine
2280
+ * the slug or the ID of the attribute.
2281
+ *
2282
+ * @param string slug The attribute slug.
2283
+ * @param int|numeric string id The attribute ID.
2284
+ */
2285
+ function getAttributeIdentifier(slug, id) {
2286
+ return slug + ',' + id;
2287
+ }
2288
+
2289
+ /**
2290
+ * Get the attribute slug from an identifier.
2291
+ *
2292
+ * @param string identifier The attribute identifier.
2293
+ * @return string
2294
+ */
2295
+ function getAttributeSlug(identifier) {
2296
+ return identifier.split(',')[0];
2297
+ }
2298
+
2299
+ /**
2300
+ * Get the attribute ID from an identifier.
2301
+ *
2302
+ * @param string identifier The attribute identifier.
2303
+ * @return numeric string
2304
+ */
2305
+ function getAttributeID(identifier) {
2306
+ return identifier.split(',')[1];
2307
+ }
2308
+
2309
+ /**
2310
+ * When the display mode is 'Attribute' search for and select product attributes to pull products from.
2311
+ */
2312
+
2313
+ var ProductsAttributeSelect = exports.ProductsAttributeSelect = function (_React$Component) {
2314
+ _inherits(ProductsAttributeSelect, _React$Component);
2315
+
2316
+ /**
2317
+ * Constructor.
2318
+ */
2319
+ function ProductsAttributeSelect(props) {
2320
+ _classCallCheck(this, ProductsAttributeSelect);
2321
+
2322
+ /**
2323
+ * The first item in props.selected_display_setting is the attribute slug and id separated by a comma.
2324
+ * This is to work around limitations in the API which sometimes requires a slug and sometimes an id.
2325
+ * The rest of the elements in selected_display_setting are the term ids for any selected terms.
2326
+ */
2327
+ var _this = _possibleConstructorReturn(this, (ProductsAttributeSelect.__proto__ || Object.getPrototypeOf(ProductsAttributeSelect)).call(this, props));
2328
+
2329
+ _this.state = {
2330
+ selectedAttribute: props.selected_display_setting.length ? props.selected_display_setting[0] : '',
2331
+ selectedTerms: props.selected_display_setting.length > 1 ? props.selected_display_setting.slice(1) : [],
2332
+ filterQuery: ''
2333
+ };
2334
+
2335
+ _this.setSelectedAttribute = _this.setSelectedAttribute.bind(_this);
2336
+ _this.addTerm = _this.addTerm.bind(_this);
2337
+ _this.removeTerm = _this.removeTerm.bind(_this);
2338
+ return _this;
2339
+ }
2340
+
2341
+ /**
2342
+ * Set the selected attribute.
2343
+ *
2344
+ * @param identifier string Attribute slug and id separated by a comma.
2345
+ */
2346
+
2347
+
2348
+ _createClass(ProductsAttributeSelect, [{
2349
+ key: 'setSelectedAttribute',
2350
+ value: function setSelectedAttribute(identifier) {
2351
+ this.setState({
2352
+ selectedAttribute: identifier,
2353
+ selectedTerms: []
2354
+ });
2355
+
2356
+ this.props.update_display_setting_callback([identifier]);
2357
+ }
2358
+
2359
+ /**
2360
+ * Add a term to the selected attribute's terms.
2361
+ *
2362
+ * @param id int Term id.
2363
+ */
2364
+
2365
+ }, {
2366
+ key: 'addTerm',
2367
+ value: function addTerm(id) {
2368
+ var terms = this.state.selectedTerms;
2369
+ terms.push(id);
2370
+ this.setState({
2371
+ selectedTerms: terms
2372
+ });
2373
+
2374
+ var displaySetting = [this.state.selectedAttribute];
2375
+ displaySetting = displaySetting.concat(terms);
2376
+ this.props.update_display_setting_callback(displaySetting);
2377
+ }
2378
+
2379
+ /**
2380
+ * Remove a term from the selected attribute's terms.
2381
+ *
2382
+ * @param id int Term id.
2383
+ */
2384
+
2385
+ }, {
2386
+ key: 'removeTerm',
2387
+ value: function removeTerm(id) {
2388
+ var newTerms = [];
2389
+ var _iteratorNormalCompletion = true;
2390
+ var _didIteratorError = false;
2391
+ var _iteratorError = undefined;
2392
+
2393
+ try {
2394
+ for (var _iterator = this.state.selectedTerms[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
2395
+ var termId = _step.value;
2396
+
2397
+ if (termId !== id) {
2398
+ newTerms.push(termId);
2399
+ }
2400
+ }
2401
+ } catch (err) {
2402
+ _didIteratorError = true;
2403
+ _iteratorError = err;
2404
+ } finally {
2405
+ try {
2406
+ if (!_iteratorNormalCompletion && _iterator.return) {
2407
+ _iterator.return();
2408
+ }
2409
+ } finally {
2410
+ if (_didIteratorError) {
2411
+ throw _iteratorError;
2412
+ }
2413
+ }
2414
+ }
2415
+
2416
+ this.setState({
2417
+ selectedTerms: newTerms
2418
+ });
2419
+
2420
+ var displaySetting = [this.state.selectedAttribute];
2421
+ displaySetting = displaySetting.concat(newTerms);
2422
+ this.props.update_display_setting_callback(displaySetting);
2423
+ }
2424
+
2425
+ /**
2426
+ * Update the search results when typing in the attributes box.
2427
+ *
2428
+ * @param evt Event object
2429
+ */
2430
+
2431
+ }, {
2432
+ key: 'updateFilter',
2433
+ value: function updateFilter(evt) {
2434
+ this.setState({
2435
+ filterQuery: evt.target.value
2436
+ });
2437
+ }
2438
+
2439
+ /**
2440
+ * Render the whole section.
2441
+ */
2442
+
2443
+ }, {
2444
+ key: 'render',
2445
+ value: function render() {
2446
+ return wp.element.createElement(
2447
+ 'div',
2448
+ { className: 'wc-products-list-card wc-products-list-card--taxonomy wc-products-list-card--taxonomy-atributes' },
2449
+ wp.element.createElement(ProductAttributeFilter, { updateFilter: this.updateFilter.bind(this) }),
2450
+ wp.element.createElement(ProductAttributeList, {
2451
+ selectedAttribute: this.state.selectedAttribute,
2452
+ selectedTerms: this.state.selectedTerms,
2453
+ filterQuery: this.state.filterQuery,
2454
+ setSelectedAttribute: this.setSelectedAttribute.bind(this),
2455
+ addTerm: this.addTerm.bind(this),
2456
+ removeTerm: this.removeTerm.bind(this)
2457
+ })
2458
+ );
2459
+ }
2460
+ }]);
2461
+
2462
+ return ProductsAttributeSelect;
2463
+ }(React.Component);
2464
+
2465
+ /**
2466
+ * Search area for filtering through the attributes list.
2467
+ */
2468
+
2469
+
2470
+ var ProductAttributeFilter = function ProductAttributeFilter(props) {
2471
+ return wp.element.createElement(
2472
+ 'div',
2473
+ { className: 'wc-products-list-card__input-wrapper' },
2474
+ wp.element.createElement(Dashicon, { icon: 'search' }),
2475
+ wp.element.createElement('input', { className: 'wc-products-list-card__search', type: 'search', placeholder: __('Search for attributes'), onChange: props.updateFilter })
2476
+ );
2477
+ };
2478
+
2479
+ /**
2480
+ * List of attributes.
2481
+ */
2482
+ var ProductAttributeList = withAPIData(function (props) {
2483
+ return {
2484
+ attributes: '/wc/v2/products/attributes'
2485
+ };
2486
+ })(function (_ref) {
2487
+ var attributes = _ref.attributes,
2488
+ selectedAttribute = _ref.selectedAttribute,
2489
+ filterQuery = _ref.filterQuery,
2490
+ selectedTerms = _ref.selectedTerms,
2491
+ setSelectedAttribute = _ref.setSelectedAttribute,
2492
+ addTerm = _ref.addTerm,
2493
+ removeTerm = _ref.removeTerm;
2494
+
2495
+ if (!attributes.data) {
2496
+ return __('Loading');
2497
+ }
2498
+
2499
+ if (0 === attributes.data.length) {
2500
+ return __('No attributes found');
2501
+ }
2502
+
2503
+ var filter = filterQuery.toLowerCase();
2504
+ var attributeElements = [];
2505
+ var _iteratorNormalCompletion2 = true;
2506
+ var _didIteratorError2 = false;
2507
+ var _iteratorError2 = undefined;
2508
+
2509
+ try {
2510
+ for (var _iterator2 = attributes.data[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
2511
+ var attribute = _step2.value;
2512
+
2513
+
2514
+ // Filter out attributes that don't match the search query.
2515
+ if (filter.length && -1 === attribute.name.toLowerCase().indexOf(filter)) {
2516
+ continue;
2517
+ }
2518
+
2519
+ if (PRODUCT_ATTRIBUTE_DATA.hasOwnProperty(attribute.slug)) {
2520
+ attributeElements.push(wp.element.createElement(ProductAttributeElement, {
2521
+ selectedAttribute: selectedAttribute,
2522
+ selectedTerms: selectedTerms,
2523
+ attribute: attribute,
2524
+ setSelectedAttribute: setSelectedAttribute,
2525
+ addTerm: addTerm,
2526
+ removeTerm: removeTerm
2527
+ }));
2528
+ } else {
2529
+ attributeElements.push(wp.element.createElement(UncachedProductAttributeElement, {
2530
+ selectedAttribute: selectedAttribute,
2531
+ selectedTerms: selectedTerms,
2532
+ attribute: attribute,
2533
+ setSelectedAttribute: setSelectedAttribute,
2534
+ addTerm: addTerm,
2535
+ removeTerm: removeTerm
2536
+ }));
2537
+ }
2538
+ }
2539
+ } catch (err) {
2540
+ _didIteratorError2 = true;
2541
+ _iteratorError2 = err;
2542
+ } finally {
2543
+ try {
2544
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
2545
+ _iterator2.return();
2546
+ }
2547
+ } finally {
2548
+ if (_didIteratorError2) {
2549
+ throw _iteratorError2;
2550
+ }
2551
+ }
2552
+ }
2553
+
2554
+ return wp.element.createElement(
2555
+ 'div',
2556
+ { className: 'wc-products-list-card__results' },
2557
+ attributeElements
2558
+ );
2559
+ });
2560
+
2561
+ /**
2562
+ * Caches then renders a product attribute term element.
2563
+ */
2564
+ var UncachedProductAttributeElement = withAPIData(function (props) {
2565
+ return {
2566
+ terms: '/wc/v2/products/attributes/' + props.attribute.id + '/terms'
2567
+ };
2568
+ })(function (_ref2) {
2569
+ var terms = _ref2.terms,
2570
+ selectedAttribute = _ref2.selectedAttribute,
2571
+ selectedTerms = _ref2.selectedTerms,
2572
+ attribute = _ref2.attribute,
2573
+ setSelectedAttribute = _ref2.setSelectedAttribute,
2574
+ addTerm = _ref2.addTerm,
2575
+ removeTerm = _ref2.removeTerm;
2576
+
2577
+ if (!terms.data || 0 === terms.data.length) {
2578
+ return null;
2579
+ }
2580
+
2581
+ // Populate cache.
2582
+ PRODUCT_ATTRIBUTE_DATA[attribute.slug] = { terms: [] };
2583
+
2584
+ var totalCount = 0;
2585
+ var _iteratorNormalCompletion3 = true;
2586
+ var _didIteratorError3 = false;
2587
+ var _iteratorError3 = undefined;
2588
+
2589
+ try {
2590
+ for (var _iterator3 = terms.data[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
2591
+ var term = _step3.value;
2592
+
2593
+ totalCount += term.count;
2594
+ PRODUCT_ATTRIBUTE_DATA[attribute.slug].terms.push(term);
2595
+ }
2596
+ } catch (err) {
2597
+ _didIteratorError3 = true;
2598
+ _iteratorError3 = err;
2599
+ } finally {
2600
+ try {
2601
+ if (!_iteratorNormalCompletion3 && _iterator3.return) {
2602
+ _iterator3.return();
2603
+ }
2604
+ } finally {
2605
+ if (_didIteratorError3) {
2606
+ throw _iteratorError3;
2607
+ }
2608
+ }
2609
+ }
2610
+
2611
+ PRODUCT_ATTRIBUTE_DATA[attribute.slug].count = totalCount;
2612
+
2613
+ return wp.element.createElement(ProductAttributeElement, {
2614
+ selectedAttribute: selectedAttribute,
2615
+ selectedTerms: selectedTerms,
2616
+ attribute: attribute,
2617
+ setSelectedAttribute: setSelectedAttribute,
2618
+ addTerm: addTerm,
2619
+ removeTerm: removeTerm
2620
+ });
2621
+ });
2622
+
2623
+ /**
2624
+ * A product attribute term element.
2625
+ */
2626
+
2627
+ var ProductAttributeElement = function (_React$Component2) {
2628
+ _inherits(ProductAttributeElement, _React$Component2);
2629
+
2630
+ /**
2631
+ * Constructor.
2632
+ */
2633
+ function ProductAttributeElement(props) {
2634
+ _classCallCheck(this, ProductAttributeElement);
2635
+
2636
+ var _this2 = _possibleConstructorReturn(this, (ProductAttributeElement.__proto__ || Object.getPrototypeOf(ProductAttributeElement)).call(this, props));
2637
+
2638
+ _this2.handleAttributeChange = _this2.handleAttributeChange.bind(_this2);
2639
+ _this2.handleTermChange = _this2.handleTermChange.bind(_this2);
2640
+ return _this2;
2641
+ }
2642
+
2643
+ /**
2644
+ * Propagate and reset values when the selected attribute is changed.
2645
+ *
2646
+ * @param evt Event object
2647
+ */
2648
+
2649
+
2650
+ _createClass(ProductAttributeElement, [{
2651
+ key: 'handleAttributeChange',
2652
+ value: function handleAttributeChange(evt) {
2653
+ if (!evt.target.checked) {
2654
+ return;
2655
+ }
2656
+
2657
+ this.props.setSelectedAttribute(evt.target.value);
2658
+ }
2659
+
2660
+ /**
2661
+ * Add or remove selected terms.
2662
+ *
2663
+ * @param evt Event object
2664
+ */
2665
+
2666
+ }, {
2667
+ key: 'handleTermChange',
2668
+ value: function handleTermChange(evt) {
2669
+ if (evt.target.checked) {
2670
+ this.props.addTerm(evt.target.value);
2671
+ } else {
2672
+ this.props.removeTerm(evt.target.value);
2673
+ }
2674
+ }
2675
+
2676
+ /**
2677
+ * Render the details for one attribute.
2678
+ */
2679
+
2680
+ }, {
2681
+ key: 'render',
2682
+ value: function render() {
2683
+ var _this3 = this;
2684
+
2685
+ var attribute = PRODUCT_ATTRIBUTE_DATA[this.props.attribute.slug];
2686
+ var isSelected = this.props.selectedAttribute === getAttributeIdentifier(this.props.attribute.slug, this.props.attribute.id);
2687
+
2688
+ var attributeTerms = null;
2689
+ if (isSelected) {
2690
+ attributeTerms = wp.element.createElement(
2691
+ 'ul',
2692
+ null,
2693
+ attribute.terms.map(function (term) {
2694
+ return wp.element.createElement(
2695
+ 'li',
2696
+ { className: 'wc-products-list-card__item' },
2697
+ wp.element.createElement(
2698
+ 'label',
2699
+ { className: 'wc-products-list-card__content' },
2700
+ wp.element.createElement('input', { type: 'checkbox',
2701
+ value: term.id,
2702
+ onChange: _this3.handleTermChange,
2703
+ checked: _this3.props.selectedTerms.includes(String(term.id))
2704
+ }),
2705
+ term.name,
2706
+ wp.element.createElement(
2707
+ 'span',
2708
+ { className: 'wc-products-list-card__taxonomy-count' },
2709
+ term.count
2710
+ )
2711
+ )
2712
+ );
2713
+ })
2714
+ );
2715
+ }
2716
+
2717
+ var cssClasses = ['wc-products-list-card--taxonomy-atributes__atribute'];
2718
+
2719
+ if (isSelected) {
2720
+ cssClasses.push('wc-products-list-card__accordion-open');
2721
+ }
2722
+
2723
+ return wp.element.createElement(
2724
+ 'div',
2725
+ { className: cssClasses.join(' ') },
2726
+ wp.element.createElement(
2727
+ 'div',
2728
+ null,
2729
+ wp.element.createElement(
2730
+ 'label',
2731
+ { className: 'wc-products-list-card__content' },
2732
+ wp.element.createElement('input', { type: 'radio',
2733
+ value: getAttributeIdentifier(this.props.attribute.slug, this.props.attribute.id),
2734
+ onChange: this.handleAttributeChange,
2735
+ checked: isSelected
2736
+ }),
2737
+ this.props.attribute.name,
2738
+ wp.element.createElement(
2739
+ 'span',
2740
+ { className: 'wc-products-list-card__taxonomy-count' },
2741
+ attribute.count
2742
+ )
2743
+ )
2744
+ ),
2745
+ attributeTerms
2746
+ );
2747
+ }
2748
+ }]);
2749
+
2750
+ return ProductAttributeElement;
2751
+ }(React.Component);
2752
+
2753
+ /***/ })
2754
+ /******/ ]);
assets/js/products-block.jsx ADDED
@@ -0,0 +1,811 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { __ } = wp.i18n;
2
+ const { RawHTML } = wp.element;
3
+ const { registerBlockType, InspectorControls, BlockControls } = wp.blocks;
4
+ const { Toolbar, withAPIData, Dropdown, Dashicon, RangeControl, Tooltip, SelectControl } = wp.components;
5
+
6
+ import { ProductsSpecificSelect } from './views/specific-select.jsx';
7
+ import { ProductsCategorySelect } from './views/category-select.jsx';
8
+ import { ProductsAttributeSelect, getAttributeSlug, getAttributeID } from './views/attribute-select.jsx';
9
+
10
+ /**
11
+ * A setting has the following properties:
12
+ * title - Display title of the setting.
13
+ * description - Display description of the setting.
14
+ * value - Display setting slug to set when selected.
15
+ * group_container - (optional) If set the setting is a parent container.
16
+ */
17
+ const PRODUCTS_BLOCK_DISPLAY_SETTINGS = {
18
+ 'specific' : {
19
+ title: __( 'Individual products' ),
20
+ description: __( 'Hand-pick which products to display' ),
21
+ value: 'specific',
22
+ },
23
+ 'category' : {
24
+ title: __( 'Product category' ),
25
+ description: __( 'Display products from a specific category or multiple categories' ),
26
+ value: 'category',
27
+ },
28
+ 'filter' : {
29
+ title: __( 'Filter products' ),
30
+ description: __( 'E.g. featured products, or products with a specific attribute like size or color' ),
31
+ value: 'filter',
32
+ group_container: 'filter'
33
+ },
34
+ 'featured' : {
35
+ title: __( 'Featured products' ),
36
+ description: '',
37
+ value: 'featured',
38
+ },
39
+ 'on_sale' : {
40
+ title: __( 'On sale' ),
41
+ description: '',
42
+ value: 'on_sale',
43
+ },
44
+ 'attribute' : {
45
+ title: __( 'Attribute' ),
46
+ description: '',
47
+ value: 'attribute',
48
+ },
49
+ 'all' : {
50
+ title: __( 'All products' ),
51
+ description: __( 'Display all products ordered chronologically, alphabetically, by price, by rating or by sales' ),
52
+ value: 'all',
53
+ }
54
+ };
55
+
56
+ /**
57
+ * One option from the list of all available ways to display products.
58
+ */
59
+ class ProductsBlockSettingsEditorDisplayOption extends React.Component {
60
+ render() {
61
+ let icon = 'arrow-right-alt2';
62
+
63
+ if ( 'filter' === this.props.value && this.props.extended ) {
64
+ icon = 'arrow-down-alt2';
65
+ }
66
+
67
+ let classes = 'wc-products-display-options__option wc-products-display-options__option--' + this.props.value;
68
+
69
+ if ( this.props.current === this.props.value ) {
70
+ icon = 'yes';
71
+ classes += ' wc-products-display-options__option--current';
72
+ }
73
+
74
+ return (
75
+ <div className={ classes } onClick={ () => { this.props.current !== this.props.value && this.props.update_display_callback( this.props.value ) } } >
76
+ <div className="wc-products-display-options__option-content">
77
+ <span className="wc-products-display-options__option-title">{ this.props.title }</span>
78
+ <p className="wc-products-display-options__option-description">{ this.props.description }</p>
79
+ </div>
80
+ <div className="wc-products-display-options__icon">
81
+ <Dashicon icon={ icon } />
82
+ </div>
83
+ </div>
84
+ );
85
+ }
86
+ }
87
+
88
+ /**
89
+ * A list of all available ways to display products.
90
+ */
91
+ class ProductsBlockSettingsEditorDisplayOptions extends React.Component {
92
+
93
+ /**
94
+ * Constructor.
95
+ */
96
+ constructor( props ) {
97
+ super( props );
98
+
99
+ this.setWrapperRef = this.setWrapperRef.bind( this );
100
+ this.handleClickOutside = this.handleClickOutside.bind( this );
101
+ }
102
+
103
+ /**
104
+ * Hook in the listener for closing menu when clicked outside.
105
+ */
106
+ componentDidMount() {
107
+ if ( this.props.existing ) {
108
+ document.addEventListener( 'mousedown', this.handleClickOutside );
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Remove the listener for closing menu when clicked outside.
114
+ */
115
+ componentWillUnmount() {
116
+ if ( this.props.existing ) {
117
+ document.removeEventListener( 'mousedown', this.handleClickOutside );
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Set the wrapper reference.
123
+ *
124
+ * @param node DOMNode
125
+ */
126
+ setWrapperRef( node ) {
127
+ this.wrapperRef = node;
128
+ }
129
+
130
+ /**
131
+ * Close the menu when user clicks outside the search area.
132
+ */
133
+ handleClickOutside( evt ) {
134
+ if ( this.wrapperRef && ! this.wrapperRef.contains( event.target ) && 'wc-products-settings-heading__change-button button-link' !== event.target.getAttribute( 'class' ) ) {
135
+ this.props.closeMenu();
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Render the list of options.
141
+ */
142
+ render() {
143
+ let classes = 'wc-products-display-options';
144
+
145
+ if ( this.props.extended ) {
146
+ classes += ' wc-products-display-options--extended';
147
+ }
148
+
149
+ if ( this.props.existing ) {
150
+ classes += ' wc-products-display-options--popover';
151
+ }
152
+
153
+ let display_settings = [];
154
+ for ( var setting_key in PRODUCTS_BLOCK_DISPLAY_SETTINGS ) {
155
+ display_settings.push( <ProductsBlockSettingsEditorDisplayOption { ...PRODUCTS_BLOCK_DISPLAY_SETTINGS[ setting_key ] } update_display_callback={ this.props.update_display_callback } extended={ this.props.extended } current={ this.props.current } /> );
156
+ }
157
+
158
+ let arrow = <span className="wc-products-display-options--popover__arrow"></span>;
159
+ let description = <p className="wc-products-block-description">{ __( 'Choose which products you\'d like to display:' ) }</p>;
160
+
161
+ return (
162
+ <div className={ classes } ref={ this.setWrapperRef }>
163
+ { this.props.existing && arrow }
164
+ { ! this.props.existing && description }
165
+ { display_settings }
166
+ </div>
167
+ );
168
+ }
169
+ }
170
+
171
+ /**
172
+ * The products block when in Edit mode.
173
+ */
174
+ class ProductsBlockSettingsEditor extends React.Component {
175
+
176
+ /**
177
+ * Constructor.
178
+ */
179
+ constructor( props ) {
180
+ super( props );
181
+ this.state = {
182
+ display: props.selected_display,
183
+ menu_visible: props.selected_display ? false : true,
184
+ expanded_group: '',
185
+ }
186
+
187
+ this.updateDisplay = this.updateDisplay.bind( this );
188
+ this.closeMenu = this.closeMenu.bind( this );
189
+ }
190
+
191
+ /**
192
+ * Update the display settings for the block.
193
+ *
194
+ * @param value String
195
+ */
196
+ updateDisplay( value ) {
197
+
198
+ // If not a group update display.
199
+ let new_state = {
200
+ display: value,
201
+ menu_visible: false,
202
+ expanded_group: '',
203
+ };
204
+
205
+ const is_group = 'undefined' !== PRODUCTS_BLOCK_DISPLAY_SETTINGS[ value ].group_container && PRODUCTS_BLOCK_DISPLAY_SETTINGS[ value ].group_container;
206
+
207
+ if ( is_group ) {
208
+ // If the group has not been expanded, expand it.
209
+ new_state = {
210
+ menu_visible: true,
211
+ expanded_group: value,
212
+ }
213
+
214
+ // If the group has already been expanded, collapse it.
215
+ if ( this.state.expanded_group === PRODUCTS_BLOCK_DISPLAY_SETTINGS[ value ].group_container ) {
216
+ new_state.expanded_group = '';
217
+ }
218
+ }
219
+
220
+ this.setState( new_state );
221
+
222
+ // Only update the display setting if a non-group setting was selected.
223
+ if ( ! is_group ) {
224
+ this.props.update_display_callback( value );
225
+ }
226
+ }
227
+
228
+ closeMenu() {
229
+ this.setState( {
230
+ menu_visible: false,
231
+ } );
232
+ }
233
+
234
+ /**
235
+ * Render the display settings dropdown and any extra contextual settings.
236
+ */
237
+ render() {
238
+ let extra_settings = null;
239
+ if ( 'specific' === this.state.display ) {
240
+ extra_settings = <ProductsSpecificSelect { ...this.props } />;
241
+ } else if ( 'category' === this.state.display ) {
242
+ extra_settings = <ProductsCategorySelect { ...this.props } />;
243
+ } else if ( 'attribute' === this.state.display ) {
244
+ extra_settings = <ProductsAttributeSelect { ...this.props } />
245
+ }
246
+
247
+ const menu = this.state.menu_visible ? <ProductsBlockSettingsEditorDisplayOptions extended={ this.state.expanded_group ? true : false } existing={ this.state.display ? true : false } current={ this.state.display } closeMenu={ this.closeMenu } update_display_callback={ this.updateDisplay } /> : null;
248
+
249
+ let heading = null;
250
+ if ( this.state.display ) {
251
+ const group_options = [ 'featured', 'on_sale', 'attribute' ];
252
+ let should_group_expand = group_options.includes( this.state.display ) ? this.state.display : '';
253
+ let menu_link = <button type="button" className="wc-products-settings-heading__change-button button-link" onClick={ () => { this.setState( { menu_visible: ! this.state.menu_visible, expanded_group: should_group_expand } ) } }>{ __( 'Display different products' ) }</button>;
254
+
255
+ heading = (
256
+ <div className="wc-products-settings-heading">
257
+ <div className="wc-products-settings-heading__current">
258
+ { __( 'Displaying ' ) }
259
+ <strong>{ __( PRODUCTS_BLOCK_DISPLAY_SETTINGS[ this.state.display ].title ) }</strong>
260
+ </div>
261
+ <div className="wc-products-settings-heading__change">
262
+ { menu_link }
263
+ </div>
264
+ </div>
265
+ );
266
+ }
267
+
268
+ let done_button = <button type="button" className="button wc-products-settings__footer-button" onClick={ this.props.done_callback }>{ __( 'Done' ) }</button>;
269
+ if ( ['', 'specific', 'category', 'attribute'].includes( this.state.display ) && ! this.props.selected_display_setting.length ) {
270
+ const done_tooltips = {
271
+ '': __( 'Please select which products you\'d like to display' ),
272
+ specific: __( 'Please search for and select products to display' ),
273
+ category: __( 'Please select at least one category to display' ),
274
+ attribute: __( 'Please select an attribute' ),
275
+ }
276
+
277
+ done_button = (
278
+ <Tooltip text={ done_tooltips[ this.state.display ] } >
279
+ <button type="button" className="button wc-products-settings__footer-button disabled">{ __( 'Done' ) }</button>
280
+ </Tooltip>
281
+ );
282
+ }
283
+
284
+
285
+ return (
286
+ <div className={ 'wc-products-settings ' + ( this.state.expanded_group ? 'expanded-group-' + this.state.expanded_group : '' ) }>
287
+ <h4 className="wc-products-settings__title"><Dashicon icon={ 'screenoptions' } /> { __( 'Products' ) }</h4>
288
+
289
+ { heading }
290
+
291
+ { menu }
292
+
293
+ { extra_settings }
294
+
295
+ <div className="wc-products-settings__footer">
296
+ { done_button }
297
+ </div>
298
+ </div>
299
+ );
300
+ }
301
+ }
302
+
303
+ /**
304
+ * One product in the product block preview.
305
+ */
306
+ class ProductPreview extends React.Component {
307
+
308
+ render() {
309
+ const { attributes, product } = this.props;
310
+
311
+ let image = null;
312
+ if ( product.images.length ) {
313
+ image = <img src={ product.images[0].src } />
314
+ }
315
+
316
+ return (
317
+ <div className="product-preview">
318
+ { image }
319
+ <div className="product-title">{ product.name }</div>
320
+ <div className="product-price" dangerouslySetInnerHTML={ { __html: product.price_html } } />
321
+ <span className="product-add-to-cart">{ __( 'Add to cart' ) }</span>
322
+ </div>
323
+ );
324
+ }
325
+ }
326
+
327
+ /**
328
+ * Renders a preview of what the block will look like with current settings.
329
+ */
330
+ const ProductsBlockPreview = withAPIData( ( { attributes } ) => {
331
+
332
+ const { columns, rows, display, display_setting, orderby } = attributes;
333
+
334
+ let query = {
335
+ per_page: rows * columns,
336
+ };
337
+
338
+ if ( 'specific' === display ) {
339
+ query.include = display_setting.join( ',' );
340
+ query.per_page = display_setting.length;
341
+ } else if ( 'category' === display ) {
342
+ query.category = display_setting.join( ',' );
343
+ } else if ( 'attribute' === display && display_setting.length ) {
344
+ query.attribute = getAttributeSlug( display_setting[0] );
345
+
346
+ if ( display_setting.length > 1 ) {
347
+ query.attribute_term = display_setting.slice( 1 ).join( ',' );
348
+ }
349
+ } else if ( 'featured' === display ) {
350
+ query.featured = 1;
351
+ } else if ( 'on_sale' === display ) {
352
+ query.on_sale = 1;
353
+ }
354
+
355
+ // @todo Add support for orderby by sales, rating, and price to the API.
356
+ if ( 'title' === orderby || 'date' === orderby ) {
357
+ query.orderby = orderby;
358
+
359
+ if ( 'title' === orderby ) {
360
+ query.order = 'asc';
361
+ }
362
+ }
363
+
364
+ let query_string = '?';
365
+ for ( const key of Object.keys( query ) ) {
366
+ query_string += key + '=' + query[ key ] + '&';
367
+ }
368
+
369
+ return {
370
+ products: '/wc/v2/products' + query_string
371
+ };
372
+
373
+ } )( ( { products, attributes } ) => {
374
+
375
+ if ( ! products.data ) {
376
+ return __( 'Loading' );
377
+ }
378
+
379
+ if ( 0 === products.data.length ) {
380
+ return __( 'No products found' );
381
+ }
382
+
383
+ const classes = "wc-products-block-preview cols-" + attributes.columns;
384
+
385
+ return (
386
+ <div className={ classes }>
387
+ { products.data.map( ( product ) => (
388
+ <ProductPreview key={ product.id } product={ product } attributes={ attributes } />
389
+ ) ) }
390
+ </div>
391
+ );
392
+ } );
393
+
394
+ /**
395
+ * Information about current block settings rendered in the sidebar.
396
+ */
397
+ const ProductsBlockSidebarInfo = withAPIData( ( { attributes } ) => {
398
+
399
+ const { display, display_setting } = attributes;
400
+
401
+ if ( 'attribute' === display && display_setting.length ) {
402
+ const ID = getAttributeID( display_setting[0] );
403
+ const terms = display_setting.slice( 1 ).join( ', ' );
404
+ const endpoints = {
405
+ attributeInfo: '/wc/v2/products/attributes/' + ID,
406
+ }
407
+
408
+ if ( terms.length ) {
409
+ endpoints.termInfo = '/wc/v2/products/attributes/' + ID + '/terms?include=' + terms;
410
+ }
411
+
412
+ return endpoints;
413
+
414
+ } else if ( 'category' === display && display_setting.length ) {
415
+ return {
416
+ categoriesInfo: '/wc/v2/products/categories?include=' + display_setting.join( ',' ),
417
+ };
418
+ }
419
+
420
+ return {};
421
+
422
+ } )( ( { attributes, categoriesInfo, attributeInfo, termInfo } ) => {
423
+
424
+ let descriptions = [
425
+ // Standard description of selected scope.
426
+ PRODUCTS_BLOCK_DISPLAY_SETTINGS[ attributes.display ].title
427
+ ];
428
+
429
+ // Description of categories selected scope.
430
+ if ( categoriesInfo && categoriesInfo.data && categoriesInfo.data.length ) {
431
+ let descriptionText = __( 'Product categories: ' );
432
+ const categories = [];
433
+ for ( let category of categoriesInfo.data ) {
434
+ categories.push( category.name );
435
+ }
436
+ descriptionText += categories.join( ', ' );
437
+
438
+ descriptions = [
439
+ descriptionText
440
+ ];
441
+
442
+ // Description of attributes selected scope.
443
+ } else if ( attributeInfo && attributeInfo.data ) {
444
+ descriptions = [
445
+ __( 'Attribute: ' ) + attributeInfo.data.name
446
+ ];
447
+
448
+ if ( termInfo && termInfo.data && termInfo.data.length ) {
449
+ let termDescriptionText = __( "Terms: " );
450
+ const terms = []
451
+ for ( const term of termInfo.data ) {
452
+ terms.push( term.name );
453
+ }
454
+ termDescriptionText += terms.join( ', ' );
455
+ descriptions.push( termDescriptionText );
456
+ }
457
+ }
458
+
459
+ return (
460
+ <div>
461
+ { descriptions.map( ( description ) => (
462
+ <div className="scope-description">{ description }</div>
463
+ ) ) }
464
+ </div>
465
+ );
466
+ } );
467
+
468
+ /**
469
+ * The main products block UI.
470
+ */
471
+ class ProductsBlock extends React.Component {
472
+
473
+ /**
474
+ * Constructor.
475
+ */
476
+ constructor( props ) {
477
+ super( props );
478
+
479
+ this.getInspectorControls = this.getInspectorControls.bind( this );
480
+ this.getToolbarControls = this.getToolbarControls.bind( this );
481
+ this.getBlockDescription = this.getBlockDescription.bind( this );
482
+ this.getPreview = this.getPreview.bind( this );
483
+ this.getSettingsEditor = this.getSettingsEditor.bind( this );
484
+ }
485
+
486
+ /**
487
+ * Get the components for the sidebar settings area that is rendered while focused on a Products block.
488
+ *
489
+ * @return Component
490
+ */
491
+ getInspectorControls() {
492
+ const { attributes, setAttributes } = this.props;
493
+ const { rows, columns, display, display_setting, orderby, edit_mode } = attributes;
494
+
495
+ let columnControl = (
496
+ <RangeControl
497
+ label={ __( 'Columns' ) }
498
+ value={ columns }
499
+ onChange={ ( value ) => setAttributes( { columns: value } ) }
500
+ min={ wc_product_block_data.min_columns }
501
+ max={ wc_product_block_data.max_columns }
502
+ />
503
+ );
504
+
505
+ let orderControl = (
506
+ <SelectControl
507
+ key="query-panel-select"
508
+ label={ __( 'Order Products By' ) }
509
+ value={ orderby }
510
+ options={ [
511
+ {
512
+ label: __( 'Newness - newest first' ),
513
+ value: 'date',
514
+ },
515
+ {
516
+ label: __( 'Price - low to high' ),
517
+ value: 'price_asc',
518
+ },
519
+ {
520
+ label: __( 'Price - high to low' ),
521
+ value: 'price_desc',
522
+ },
523
+ {
524
+ label: __( 'Rating - highest first' ),
525
+ value: 'rating',
526
+ },
527
+ {
528
+ label: __( 'Sales - most first' ),
529
+ value: 'popularity',
530
+ },
531
+ {
532
+ label: __( 'Title - alphabetical' ),
533
+ value: 'title',
534
+ },
535
+ ] }
536
+ onChange={ ( value ) => setAttributes( { orderby: value } ) }
537
+ />
538
+ );
539
+
540
+ // Row settings don't make sense for specific-selected products display.
541
+ let rowControl = null;
542
+ if ( 'specific' !== display ) {
543
+ rowControl = (
544
+ <RangeControl
545
+ label={ __( 'Rows' ) }
546
+ value={ rows }
547
+ onChange={ ( value ) => setAttributes( { rows: value } ) }
548
+ min={ wc_product_block_data.min_rows }
549
+ max={ wc_product_block_data.max_rows }
550
+ />
551
+ );
552
+ }
553
+
554
+ return (
555
+ <InspectorControls key="inspector">
556
+ { this.getBlockDescription() }
557
+ <h3>{ __( 'Layout' ) }</h3>
558
+ { columnControl }
559
+ { rowControl }
560
+ { orderControl }
561
+ </InspectorControls>
562
+ );
563
+ }
564
+
565
+ /**
566
+ * Get the components for the toolbar area that appears on top of the block when focused.
567
+ *
568
+ * @return Component
569
+ */
570
+ getToolbarControls() {
571
+ let props = this.props;
572
+ const { attributes, setAttributes } = props;
573
+ const { display, display_setting, edit_mode } = attributes;
574
+
575
+ // Edit button should not do anything if valid product selection has not been made.
576
+ const shouldDisableEditButton = ['', 'specific', 'category', 'attribute'].includes( display ) && ! display_setting.length;
577
+
578
+ const editButton = [
579
+ {
580
+ icon: 'edit',
581
+ title: __( 'Edit' ),
582
+ onClick: shouldDisableEditButton ? function(){} : () => setAttributes( { edit_mode: ! edit_mode } ),
583
+ isActive: edit_mode,
584
+ },
585
+ ];
586
+
587
+ return (
588
+ <BlockControls key="controls">
589
+ <Toolbar controls={ editButton } />
590
+ </BlockControls>
591
+ );
592
+ }
593
+
594
+ /**
595
+ * Get a description of the current block settings.
596
+ *
597
+ * @return Component
598
+ */
599
+ getBlockDescription() {
600
+ const { attributes, setAttributes } = this.props;
601
+ const { display, display_setting, edit_mode } = attributes;
602
+
603
+ if ( ! display.length ) {
604
+ return null;
605
+ }
606
+
607
+ function editQuicklinkHandler() {
608
+ setAttributes( {
609
+ edit_mode: true,
610
+ } );
611
+
612
+ // @todo center in view
613
+ }
614
+
615
+ let editQuickLink = null;
616
+ if ( ! attributes.edit_mode ) {
617
+ editQuickLink = (
618
+ <div className="wc-products-scope-description--edit-quicklink">
619
+ <a onClick={ editQuicklinkHandler }>{ __( 'Edit' ) }</a>
620
+ </div>
621
+ );
622
+ }
623
+
624
+ return (
625
+ <div className="wc-products-scope-descriptions">
626
+ <div className="wc-products-scope-details">
627
+ <h3>{ __( 'Current Source' ) }</h3>
628
+ <ProductsBlockSidebarInfo attributes={ attributes } />
629
+ </div>
630
+ { editQuickLink }
631
+ </div>
632
+ );
633
+ }
634
+
635
+ /**
636
+ * Get the block preview component for preview mode.
637
+ *
638
+ * @return Component
639
+ */
640
+ getPreview() {
641
+ return <ProductsBlockPreview attributes={ this.props.attributes } />;
642
+ }
643
+
644
+ /**
645
+ * Get the block edit component for edit mode.
646
+ *
647
+ * @return Component
648
+ */
649
+ getSettingsEditor() {
650
+ const { attributes, setAttributes } = this.props;
651
+ const { display, display_setting } = attributes;
652
+
653
+ const update_display_callback = ( value ) => {
654
+
655
+ // These options have setting screens that need further input from the user, so keep edit mode open.
656
+ const needsFurtherSettings = [ 'specific', 'attribute', 'category' ];
657
+
658
+ if ( display !== value ) {
659
+ setAttributes( {
660
+ display: value,
661
+ display_setting: [],
662
+ edit_mode: needsFurtherSettings.includes( value ),
663
+ } );
664
+ }
665
+ };
666
+
667
+ return (
668
+ <ProductsBlockSettingsEditor
669
+ attributes={ attributes }
670
+ selected_display={ display }
671
+ selected_display_setting={ display_setting }
672
+ update_display_callback={ update_display_callback }
673
+ update_display_setting_callback={ ( value ) => setAttributes( { display_setting: value } ) }
674
+ done_callback={ () => setAttributes( { edit_mode: false } ) }
675
+ />
676
+ );
677
+ }
678
+
679
+ render() {
680
+ const { attributes, focus } = this.props;
681
+ const { edit_mode } = attributes;
682
+
683
+ return [
684
+ ( !! focus ) ? this.getInspectorControls() : null,
685
+ ( !! focus ) ? this.getToolbarControls() : null,
686
+ edit_mode ? this.getSettingsEditor() : this.getPreview(),
687
+ ];
688
+ }
689
+ }
690
+
691
+ /**
692
+ * Register and run the products block.
693
+ */
694
+ registerBlockType( 'woocommerce/products', {
695
+ title: __( 'Products' ),
696
+ icon: 'screenoptions',
697
+ category: 'widgets',
698
+ description: __( 'Display a grid of products from a variety of sources.' ),
699
+
700
+ attributes: {
701
+
702
+ /**
703
+ * Number of columns.
704
+ */
705
+ columns: {
706
+ type: 'number',
707
+ default: wc_product_block_data.default_columns,
708
+ },
709
+
710
+ /**
711
+ * Number of rows.
712
+ */
713
+ rows: {
714
+ type: 'number',
715
+ default: wc_product_block_data.default_rows,
716
+ },
717
+
718
+ /**
719
+ * What types of products to display. 'all', 'specific', or 'category'.
720
+ */
721
+ display: {
722
+ type: 'string',
723
+ default: '',
724
+ },
725
+
726
+ /**
727
+ * Which products to display if 'display' is 'specific' or 'category'. Array of product ids or category slugs depending on setting.
728
+ */
729
+ display_setting: {
730
+ type: 'array',
731
+ default: [],
732
+ },
733
+
734
+ /**
735
+ * How to order the products: 'date', 'popularity', 'price_asc', 'price_desc' 'rating', 'title'.
736
+ */
737
+ orderby: {
738
+ type: 'string',
739
+ default: 'date',
740
+ },
741
+
742
+ /**
743
+ * Whether the block is in edit or preview mode.
744
+ */
745
+ edit_mode: {
746
+ type: 'boolean',
747
+ default: true,
748
+ },
749
+ },
750
+
751
+ /**
752
+ * Renders and manages the block.
753
+ */
754
+ edit( props ) {
755
+ return <ProductsBlock { ...props } />
756
+ },
757
+
758
+ /**
759
+ * Save the block content in the post content. Block content is saved as a products shortcode.
760
+ *
761
+ * @return string
762
+ */
763
+ save( props ) {
764
+ const { rows, columns, display, display_setting, orderby } = props.attributes;
765
+
766
+ let shortcode_atts = new Map();
767
+ if ( 'specific' !== display ) {
768
+ shortcode_atts.set( 'limit', rows * columns );
769
+ }
770
+ shortcode_atts.set( 'columns', columns );
771
+
772
+ if ( 'specific' === display ) {
773
+ shortcode_atts.set( 'ids', display_setting.join( ',' ) );
774
+ } else if ( 'category' === display ) {
775
+ shortcode_atts.set( 'category', display_setting.join( ',' ) );
776
+ } else if ( 'featured' === display ) {
777
+ shortcode_atts.set( 'visibility', 'featured' );
778
+ } else if ( 'on_sale' === display ) {
779
+ shortcode_atts.set( 'on_sale', '1' );
780
+ } else if ( 'attribute' === display ) {
781
+ const attribute = display_setting.length ? getAttributeSlug( display_setting[0] ) : '';
782
+ const terms = display_setting.length > 1 ? display_setting.slice( 1 ).join( ',' ) : '';
783
+
784
+ shortcode_atts.set( 'attribute', attribute );
785
+ if ( terms.length ) {
786
+ shortcode_atts.set( 'terms', terms );
787
+ }
788
+ }
789
+
790
+ if ( 'specific' !== display ) {
791
+ if ( 'price_desc' === orderby ) {
792
+ shortcode_atts.set( 'orderby', 'price' );
793
+ shortcode_atts.set( 'order', 'DESC' )
794
+ } else if ( 'price_asc' === orderby ) {
795
+ shortcode_atts.set( 'orderby', 'price' );
796
+ shortcode_atts.set( 'order', 'ASC' )
797
+ } else {
798
+ shortcode_atts.set( 'orderby', orderby );
799
+ }
800
+ }
801
+
802
+ // Build the shortcode string out of the set shortcode attributes.
803
+ let shortcode = '[products';
804
+ for ( let [key, value] of shortcode_atts ) {
805
+ shortcode += ' ' + key + '="' + value + '"';
806
+ }
807
+ shortcode += ']';
808
+
809
+ return <RawHTML>{ shortcode }</RawHTML>;
810
+ },
811
+ } );
assets/js/vendor/react-transition-group.js ADDED
@@ -0,0 +1,2517 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("react"), require("react-dom"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define(["react", "react-dom"], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["ReactTransitionGroup"] = factory(require("react"), require("react-dom"));
8
+ else
9
+ root["ReactTransitionGroup"] = factory(root["React"], root["ReactDOM"]);
10
+ })(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_19__) {
11
+ return /******/ (function(modules) { // webpackBootstrap
12
+ /******/ // The module cache
13
+ /******/ var installedModules = {};
14
+ /******/
15
+ /******/ // The require function
16
+ /******/ function __webpack_require__(moduleId) {
17
+ /******/
18
+ /******/ // Check if module is in cache
19
+ /******/ if(installedModules[moduleId]) {
20
+ /******/ return installedModules[moduleId].exports;
21
+ /******/ }
22
+ /******/ // Create a new module (and put it into the cache)
23
+ /******/ var module = installedModules[moduleId] = {
24
+ /******/ i: moduleId,
25
+ /******/ l: false,
26
+ /******/ exports: {}
27
+ /******/ };
28
+ /******/
29
+ /******/ // Execute the module function
30
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
+ /******/
32
+ /******/ // Flag the module as loaded
33
+ /******/ module.l = true;
34
+ /******/
35
+ /******/ // Return the exports of the module
36
+ /******/ return module.exports;
37
+ /******/ }
38
+ /******/
39
+ /******/
40
+ /******/ // expose the modules object (__webpack_modules__)
41
+ /******/ __webpack_require__.m = modules;
42
+ /******/
43
+ /******/ // expose the module cache
44
+ /******/ __webpack_require__.c = installedModules;
45
+ /******/
46
+ /******/ // identity function for calling harmony imports with the correct context
47
+ /******/ __webpack_require__.i = function(value) { return value; };
48
+ /******/
49
+ /******/ // define getter function for harmony exports
50
+ /******/ __webpack_require__.d = function(exports, name, getter) {
51
+ /******/ if(!__webpack_require__.o(exports, name)) {
52
+ /******/ Object.defineProperty(exports, name, {
53
+ /******/ configurable: false,
54
+ /******/ enumerable: true,
55
+ /******/ get: getter
56
+ /******/ });
57
+ /******/ }
58
+ /******/ };
59
+ /******/
60
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
61
+ /******/ __webpack_require__.n = function(module) {
62
+ /******/ var getter = module && module.__esModule ?
63
+ /******/ function getDefault() { return module['default']; } :
64
+ /******/ function getModuleExports() { return module; };
65
+ /******/ __webpack_require__.d(getter, 'a', getter);
66
+ /******/ return getter;
67
+ /******/ };
68
+ /******/
69
+ /******/ // Object.prototype.hasOwnProperty.call
70
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
71
+ /******/
72
+ /******/ // __webpack_public_path__
73
+ /******/ __webpack_require__.p = "";
74
+ /******/
75
+ /******/ // Load entry module and return exports
76
+ /******/ return __webpack_require__(__webpack_require__.s = 17);
77
+ /******/ })
78
+ /************************************************************************/
79
+ /******/ ([
80
+ /* 0 */
81
+ /***/ (function(module, exports, __webpack_require__) {
82
+
83
+ "use strict";
84
+
85
+
86
+ // shim for using process in browser
87
+ var process = module.exports = {};
88
+
89
+ // cached from whatever global is present so that test runners that stub it
90
+ // don't break things. But we need to wrap it in a try catch in case it is
91
+ // wrapped in strict mode code which doesn't define any globals. It's inside a
92
+ // function because try/catches deoptimize in certain engines.
93
+
94
+ var cachedSetTimeout;
95
+ var cachedClearTimeout;
96
+
97
+ function defaultSetTimout() {
98
+ throw new Error('setTimeout has not been defined');
99
+ }
100
+ function defaultClearTimeout() {
101
+ throw new Error('clearTimeout has not been defined');
102
+ }
103
+ (function () {
104
+ try {
105
+ if (typeof setTimeout === 'function') {
106
+ cachedSetTimeout = setTimeout;
107
+ } else {
108
+ cachedSetTimeout = defaultSetTimout;
109
+ }
110
+ } catch (e) {
111
+ cachedSetTimeout = defaultSetTimout;
112
+ }
113
+ try {
114
+ if (typeof clearTimeout === 'function') {
115
+ cachedClearTimeout = clearTimeout;
116
+ } else {
117
+ cachedClearTimeout = defaultClearTimeout;
118
+ }
119
+ } catch (e) {
120
+ cachedClearTimeout = defaultClearTimeout;
121
+ }
122
+ })();
123
+ function runTimeout(fun) {
124
+ if (cachedSetTimeout === setTimeout) {
125
+ //normal enviroments in sane situations
126
+ return setTimeout(fun, 0);
127
+ }
128
+ // if setTimeout wasn't available but was latter defined
129
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
130
+ cachedSetTimeout = setTimeout;
131
+ return setTimeout(fun, 0);
132
+ }
133
+ try {
134
+ // when when somebody has screwed with setTimeout but no I.E. maddness
135
+ return cachedSetTimeout(fun, 0);
136
+ } catch (e) {
137
+ try {
138
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
139
+ return cachedSetTimeout.call(null, fun, 0);
140
+ } catch (e) {
141
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
142
+ return cachedSetTimeout.call(this, fun, 0);
143
+ }
144
+ }
145
+ }
146
+ function runClearTimeout(marker) {
147
+ if (cachedClearTimeout === clearTimeout) {
148
+ //normal enviroments in sane situations
149
+ return clearTimeout(marker);
150
+ }
151
+ // if clearTimeout wasn't available but was latter defined
152
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
153
+ cachedClearTimeout = clearTimeout;
154
+ return clearTimeout(marker);
155
+ }
156
+ try {
157
+ // when when somebody has screwed with setTimeout but no I.E. maddness
158
+ return cachedClearTimeout(marker);
159
+ } catch (e) {
160
+ try {
161
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
162
+ return cachedClearTimeout.call(null, marker);
163
+ } catch (e) {
164
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
165
+ // Some versions of I.E. have different rules for clearTimeout vs setTimeout
166
+ return cachedClearTimeout.call(this, marker);
167
+ }
168
+ }
169
+ }
170
+ var queue = [];
171
+ var draining = false;
172
+ var currentQueue;
173
+ var queueIndex = -1;
174
+
175
+ function cleanUpNextTick() {
176
+ if (!draining || !currentQueue) {
177
+ return;
178
+ }
179
+ draining = false;
180
+ if (currentQueue.length) {
181
+ queue = currentQueue.concat(queue);
182
+ } else {
183
+ queueIndex = -1;
184
+ }
185
+ if (queue.length) {
186
+ drainQueue();
187
+ }
188
+ }
189
+
190
+ function drainQueue() {
191
+ if (draining) {
192
+ return;
193
+ }
194
+ var timeout = runTimeout(cleanUpNextTick);
195
+ draining = true;
196
+
197
+ var len = queue.length;
198
+ while (len) {
199
+ currentQueue = queue;
200
+ queue = [];
201
+ while (++queueIndex < len) {
202
+ if (currentQueue) {
203
+ currentQueue[queueIndex].run();
204
+ }
205
+ }
206
+ queueIndex = -1;
207
+ len = queue.length;
208
+ }
209
+ currentQueue = null;
210
+ draining = false;
211
+ runClearTimeout(timeout);
212
+ }
213
+
214
+ process.nextTick = function (fun) {
215
+ var args = new Array(arguments.length - 1);
216
+ if (arguments.length > 1) {
217
+ for (var i = 1; i < arguments.length; i++) {
218
+ args[i - 1] = arguments[i];
219
+ }
220
+ }
221
+ queue.push(new Item(fun, args));
222
+ if (queue.length === 1 && !draining) {
223
+ runTimeout(drainQueue);
224
+ }
225
+ };
226
+
227
+ // v8 likes predictible objects
228
+ function Item(fun, array) {
229
+ this.fun = fun;
230
+ this.array = array;
231
+ }
232
+ Item.prototype.run = function () {
233
+ this.fun.apply(null, this.array);
234
+ };
235
+ process.title = 'browser';
236
+ process.browser = true;
237
+ process.env = {};
238
+ process.argv = [];
239
+ process.version = ''; // empty string to avoid regexp issues
240
+ process.versions = {};
241
+
242
+ function noop() {}
243
+
244
+ process.on = noop;
245
+ process.addListener = noop;
246
+ process.once = noop;
247
+ process.off = noop;
248
+ process.removeListener = noop;
249
+ process.removeAllListeners = noop;
250
+ process.emit = noop;
251
+ process.prependListener = noop;
252
+ process.prependOnceListener = noop;
253
+
254
+ process.listeners = function (name) {
255
+ return [];
256
+ };
257
+
258
+ process.binding = function (name) {
259
+ throw new Error('process.binding is not supported');
260
+ };
261
+
262
+ process.cwd = function () {
263
+ return '/';
264
+ };
265
+ process.chdir = function (dir) {
266
+ throw new Error('process.chdir is not supported');
267
+ };
268
+ process.umask = function () {
269
+ return 0;
270
+ };
271
+
272
+ /***/ }),
273
+ /* 1 */
274
+ /***/ (function(module, exports, __webpack_require__) {
275
+
276
+ "use strict";
277
+ /* WEBPACK VAR INJECTION */(function(process) {
278
+
279
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
280
+
281
+ /**
282
+ * Copyright 2013-present, Facebook, Inc.
283
+ * All rights reserved.
284
+ *
285
+ * This source code is licensed under the BSD-style license found in the
286
+ * LICENSE file in the root directory of this source tree. An additional grant
287
+ * of patent rights can be found in the PATENTS file in the same directory.
288
+ */
289
+
290
+ if (process.env.NODE_ENV !== 'production') {
291
+ var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element') || 0xeac7;
292
+
293
+ var isValidElement = function isValidElement(object) {
294
+ return (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
295
+ };
296
+
297
+ // By explicitly using `prop-types` you are opting into new development behavior.
298
+ // http://fb.me/prop-types-in-prod
299
+ var throwOnDirectAccess = true;
300
+ module.exports = __webpack_require__(16)(isValidElement, throwOnDirectAccess);
301
+ } else {
302
+ // By explicitly using `prop-types` you are opting into new production behavior.
303
+ // http://fb.me/prop-types-in-prod
304
+ module.exports = __webpack_require__(15)();
305
+ }
306
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
307
+
308
+ /***/ }),
309
+ /* 2 */
310
+ /***/ (function(module, exports) {
311
+
312
+ module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
313
+
314
+ /***/ }),
315
+ /* 3 */
316
+ /***/ (function(module, exports, __webpack_require__) {
317
+
318
+ "use strict";
319
+
320
+
321
+ /**
322
+ * Copyright (c) 2013-present, Facebook, Inc.
323
+ *
324
+ * This source code is licensed under the MIT license found in the
325
+ * LICENSE file in the root directory of this source tree.
326
+ *
327
+ *
328
+ */
329
+
330
+ function makeEmptyFunction(arg) {
331
+ return function () {
332
+ return arg;
333
+ };
334
+ }
335
+
336
+ /**
337
+ * This function accepts and discards inputs; it has no side effects. This is
338
+ * primarily useful idiomatically for overridable function endpoints which
339
+ * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
340
+ */
341
+ var emptyFunction = function emptyFunction() {};
342
+
343
+ emptyFunction.thatReturns = makeEmptyFunction;
344
+ emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
345
+ emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
346
+ emptyFunction.thatReturnsNull = makeEmptyFunction(null);
347
+ emptyFunction.thatReturnsThis = function () {
348
+ return this;
349
+ };
350
+ emptyFunction.thatReturnsArgument = function (arg) {
351
+ return arg;
352
+ };
353
+
354
+ module.exports = emptyFunction;
355
+
356
+ /***/ }),
357
+ /* 4 */
358
+ /***/ (function(module, exports, __webpack_require__) {
359
+
360
+ "use strict";
361
+ /* WEBPACK VAR INJECTION */(function(process) {/**
362
+ * Copyright (c) 2013-present, Facebook, Inc.
363
+ *
364
+ * This source code is licensed under the MIT license found in the
365
+ * LICENSE file in the root directory of this source tree.
366
+ *
367
+ */
368
+
369
+
370
+
371
+ /**
372
+ * Use invariant() to assert state which your program assumes to be true.
373
+ *
374
+ * Provide sprintf-style format (only %s is supported) and arguments
375
+ * to provide information about what broke and what you were
376
+ * expecting.
377
+ *
378
+ * The invariant message will be stripped in production, but the invariant
379
+ * will remain to ensure logic does not differ in production.
380
+ */
381
+
382
+ var validateFormat = function validateFormat(format) {};
383
+
384
+ if (process.env.NODE_ENV !== 'production') {
385
+ validateFormat = function validateFormat(format) {
386
+ if (format === undefined) {
387
+ throw new Error('invariant requires an error message argument');
388
+ }
389
+ };
390
+ }
391
+
392
+ function invariant(condition, format, a, b, c, d, e, f) {
393
+ validateFormat(format);
394
+
395
+ if (!condition) {
396
+ var error;
397
+ if (format === undefined) {
398
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
399
+ } else {
400
+ var args = [a, b, c, d, e, f];
401
+ var argIndex = 0;
402
+ error = new Error(format.replace(/%s/g, function () {
403
+ return args[argIndex++];
404
+ }));
405
+ error.name = 'Invariant Violation';
406
+ }
407
+
408
+ error.framesToPop = 1; // we don't care about invariant's own frame
409
+ throw error;
410
+ }
411
+ }
412
+
413
+ module.exports = invariant;
414
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
415
+
416
+ /***/ }),
417
+ /* 5 */
418
+ /***/ (function(module, exports, __webpack_require__) {
419
+
420
+ "use strict";
421
+ /* WEBPACK VAR INJECTION */(function(process) {
422
+
423
+ exports.__esModule = true;
424
+ exports.EXITING = exports.ENTERED = exports.ENTERING = exports.EXITED = exports.UNMOUNTED = undefined;
425
+
426
+ var _propTypes = __webpack_require__(1);
427
+
428
+ var PropTypes = _interopRequireWildcard(_propTypes);
429
+
430
+ var _react = __webpack_require__(2);
431
+
432
+ var _react2 = _interopRequireDefault(_react);
433
+
434
+ var _reactDom = __webpack_require__(19);
435
+
436
+ var _reactDom2 = _interopRequireDefault(_reactDom);
437
+
438
+ var _PropTypes = __webpack_require__(8);
439
+
440
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
441
+
442
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
443
+
444
+ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
445
+
446
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
447
+
448
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
449
+
450
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
451
+
452
+ var UNMOUNTED = exports.UNMOUNTED = 'unmounted';
453
+ var EXITED = exports.EXITED = 'exited';
454
+ var ENTERING = exports.ENTERING = 'entering';
455
+ var ENTERED = exports.ENTERED = 'entered';
456
+ var EXITING = exports.EXITING = 'exiting';
457
+
458
+ /**
459
+ * The Transition component lets you describe a transition from one component
460
+ * state to another _over time_ with a simple declarative API. Most commonly
461
+ * it's used to animate the mounting and unmounting of a component, but can also
462
+ * be used to describe in-place transition states as well.
463
+ *
464
+ * By default the `Transition` component does not alter the behavior of the
465
+ * component it renders, it only tracks "enter" and "exit" states for the components.
466
+ * It's up to you to give meaning and effect to those states. For example we can
467
+ * add styles to a component when it enters or exits:
468
+ *
469
+ * ```jsx
470
+ * import Transition from 'react-transition-group/Transition';
471
+ *
472
+ * const duration = 300;
473
+ *
474
+ * const defaultStyle = {
475
+ * transition: `opacity ${duration}ms ease-in-out`,
476
+ * opacity: 0,
477
+ * }
478
+ *
479
+ * const transitionStyles = {
480
+ * entering: { opacity: 0 },
481
+ * entered: { opacity: 1 },
482
+ * };
483
+ *
484
+ * const Fade = ({ in: inProp }) => (
485
+ * <Transition in={inProp} timeout={duration}>
486
+ * {(state) => (
487
+ * <div style={{
488
+ * ...defaultStyle,
489
+ * ...transitionStyles[state]
490
+ * }}>
491
+ * I'm A fade Transition!
492
+ * </div>
493
+ * )}
494
+ * </Transition>
495
+ * );
496
+ * ```
497
+ *
498
+ * As noted the `Transition` component doesn't _do_ anything by itself to its child component.
499
+ * What it does do is track transition states over time so you can update the
500
+ * component (such as by adding styles or classes) when it changes states.
501
+ *
502
+ * There are 4 main states a Transition can be in:
503
+ * - `ENTERING`
504
+ * - `ENTERED`
505
+ * - `EXITING`
506
+ * - `EXITED`
507
+ *
508
+ * Transition state is toggled via the `in` prop. When `true` the component begins the
509
+ * "Enter" stage. During this stage, the component will shift from its current transition state,
510
+ * to `'entering'` for the duration of the transition and then to the `'entered'` stage once
511
+ * it's complete. Let's take the following example:
512
+ *
513
+ * ```jsx
514
+ * state= { in: false };
515
+ *
516
+ * toggleEnterState = () => {
517
+ * this.setState({ in: true });
518
+ * }
519
+ *
520
+ * render() {
521
+ * return (
522
+ * <div>
523
+ * <Transition in={this.state.in} timeout={500} />
524
+ * <button onClick={this.toggleEnterState}>Click to Enter</button>
525
+ * </div>
526
+ * );
527
+ * }
528
+ * ```
529
+ *
530
+ * When the button is clicked the component will shift to the `'entering'` state and
531
+ * stay there for 500ms (the value of `timeout`) when finally switches to `'entered'`.
532
+ *
533
+ * When `in` is `false` the same thing happens except the state moves from `'exiting'` to `'exited'`.
534
+ */
535
+
536
+ var Transition = function (_React$Component) {
537
+ _inherits(Transition, _React$Component);
538
+
539
+ function Transition(props, context) {
540
+ _classCallCheck(this, Transition);
541
+
542
+ var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context));
543
+
544
+ var parentGroup = context.transitionGroup;
545
+ // In the context of a TransitionGroup all enters are really appears
546
+ var appear = parentGroup && !parentGroup.isMounting ? props.enter : props.appear;
547
+
548
+ var initialStatus = void 0;
549
+ _this.nextStatus = null;
550
+
551
+ if (props.in) {
552
+ if (appear) {
553
+ initialStatus = EXITED;
554
+ _this.nextStatus = ENTERING;
555
+ } else {
556
+ initialStatus = ENTERED;
557
+ }
558
+ } else {
559
+ if (props.unmountOnExit || props.mountOnEnter) {
560
+ initialStatus = UNMOUNTED;
561
+ } else {
562
+ initialStatus = EXITED;
563
+ }
564
+ }
565
+
566
+ _this.state = { status: initialStatus };
567
+
568
+ _this.nextCallback = null;
569
+ return _this;
570
+ }
571
+
572
+ Transition.prototype.getChildContext = function getChildContext() {
573
+ return { transitionGroup: null }; // allows for nested Transitions
574
+ };
575
+
576
+ Transition.prototype.componentDidMount = function componentDidMount() {
577
+ this.updateStatus(true);
578
+ };
579
+
580
+ Transition.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
581
+ var _ref = this.pendingState || this.state,
582
+ status = _ref.status;
583
+
584
+ if (nextProps.in) {
585
+ if (status === UNMOUNTED) {
586
+ this.setState({ status: EXITED });
587
+ }
588
+ if (status !== ENTERING && status !== ENTERED) {
589
+ this.nextStatus = ENTERING;
590
+ }
591
+ } else {
592
+ if (status === ENTERING || status === ENTERED) {
593
+ this.nextStatus = EXITING;
594
+ }
595
+ }
596
+ };
597
+
598
+ Transition.prototype.componentDidUpdate = function componentDidUpdate() {
599
+ this.updateStatus();
600
+ };
601
+
602
+ Transition.prototype.componentWillUnmount = function componentWillUnmount() {
603
+ this.cancelNextCallback();
604
+ };
605
+
606
+ Transition.prototype.getTimeouts = function getTimeouts() {
607
+ var timeout = this.props.timeout;
608
+
609
+ var exit = void 0,
610
+ enter = void 0,
611
+ appear = void 0;
612
+
613
+ exit = enter = appear = timeout;
614
+
615
+ if (timeout != null && typeof timeout !== 'number') {
616
+ exit = timeout.exit;
617
+ enter = timeout.enter;
618
+ appear = timeout.appear;
619
+ }
620
+ return { exit: exit, enter: enter, appear: appear };
621
+ };
622
+
623
+ Transition.prototype.updateStatus = function updateStatus() {
624
+ var mounting = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
625
+
626
+ var nextStatus = this.nextStatus;
627
+
628
+ if (nextStatus !== null) {
629
+ this.nextStatus = null;
630
+ // nextStatus will always be ENTERING or EXITING.
631
+ this.cancelNextCallback();
632
+ var node = _reactDom2.default.findDOMNode(this);
633
+
634
+ if (nextStatus === ENTERING) {
635
+ this.performEnter(node, mounting);
636
+ } else {
637
+ this.performExit(node);
638
+ }
639
+ } else if (this.props.unmountOnExit && this.state.status === EXITED) {
640
+ this.setState({ status: UNMOUNTED });
641
+ }
642
+ };
643
+
644
+ Transition.prototype.performEnter = function performEnter(node, mounting) {
645
+ var _this2 = this;
646
+
647
+ var enter = this.props.enter;
648
+
649
+ var appearing = this.context.transitionGroup ? this.context.transitionGroup.isMounting : mounting;
650
+
651
+ var timeouts = this.getTimeouts();
652
+
653
+ // no enter animation skip right to ENTERED
654
+ // if we are mounting and running this it means appear _must_ be set
655
+ if (!mounting && !enter) {
656
+ this.safeSetState({ status: ENTERED }, function () {
657
+ _this2.props.onEntered(node);
658
+ });
659
+ return;
660
+ }
661
+
662
+ this.props.onEnter(node, appearing);
663
+
664
+ this.safeSetState({ status: ENTERING }, function () {
665
+ _this2.props.onEntering(node, appearing);
666
+
667
+ // FIXME: appear timeout?
668
+ _this2.onTransitionEnd(node, timeouts.enter, function () {
669
+ _this2.safeSetState({ status: ENTERED }, function () {
670
+ _this2.props.onEntered(node, appearing);
671
+ });
672
+ });
673
+ });
674
+ };
675
+
676
+ Transition.prototype.performExit = function performExit(node) {
677
+ var _this3 = this;
678
+
679
+ var exit = this.props.exit;
680
+
681
+ var timeouts = this.getTimeouts();
682
+
683
+ // no exit animation skip right to EXITED
684
+ if (!exit) {
685
+ this.safeSetState({ status: EXITED }, function () {
686
+ _this3.props.onExited(node);
687
+ });
688
+ return;
689
+ }
690
+ this.props.onExit(node);
691
+
692
+ this.safeSetState({ status: EXITING }, function () {
693
+ _this3.props.onExiting(node);
694
+
695
+ _this3.onTransitionEnd(node, timeouts.exit, function () {
696
+ _this3.safeSetState({ status: EXITED }, function () {
697
+ _this3.props.onExited(node);
698
+ });
699
+ });
700
+ });
701
+ };
702
+
703
+ Transition.prototype.cancelNextCallback = function cancelNextCallback() {
704
+ if (this.nextCallback !== null) {
705
+ this.nextCallback.cancel();
706
+ this.nextCallback = null;
707
+ }
708
+ };
709
+
710
+ Transition.prototype.safeSetState = function safeSetState(nextState, callback) {
711
+ var _this4 = this;
712
+
713
+ // We need to track pending updates for instances where a cWRP fires quickly
714
+ // after cDM and before the state flushes, which would double trigger a
715
+ // transition
716
+ this.pendingState = nextState;
717
+
718
+ // This shouldn't be necessary, but there are weird race conditions with
719
+ // setState callbacks and unmounting in testing, so always make sure that
720
+ // we can cancel any pending setState callbacks after we unmount.
721
+ callback = this.setNextCallback(callback);
722
+ this.setState(nextState, function () {
723
+ _this4.pendingState = null;
724
+ callback();
725
+ });
726
+ };
727
+
728
+ Transition.prototype.setNextCallback = function setNextCallback(callback) {
729
+ var _this5 = this;
730
+
731
+ var active = true;
732
+
733
+ this.nextCallback = function (event) {
734
+ if (active) {
735
+ active = false;
736
+ _this5.nextCallback = null;
737
+
738
+ callback(event);
739
+ }
740
+ };
741
+
742
+ this.nextCallback.cancel = function () {
743
+ active = false;
744
+ };
745
+
746
+ return this.nextCallback;
747
+ };
748
+
749
+ Transition.prototype.onTransitionEnd = function onTransitionEnd(node, timeout, handler) {
750
+ this.setNextCallback(handler);
751
+
752
+ if (node) {
753
+ if (this.props.addEndListener) {
754
+ this.props.addEndListener(node, this.nextCallback);
755
+ }
756
+ if (timeout != null) {
757
+ setTimeout(this.nextCallback, timeout);
758
+ }
759
+ } else {
760
+ setTimeout(this.nextCallback, 0);
761
+ }
762
+ };
763
+
764
+ Transition.prototype.render = function render() {
765
+ var status = this.state.status;
766
+ if (status === UNMOUNTED) {
767
+ return null;
768
+ }
769
+
770
+ var _props = this.props,
771
+ children = _props.children,
772
+ childProps = _objectWithoutProperties(_props, ['children']);
773
+ // filter props for Transtition
774
+
775
+
776
+ delete childProps.in;
777
+ delete childProps.mountOnEnter;
778
+ delete childProps.unmountOnExit;
779
+ delete childProps.appear;
780
+ delete childProps.enter;
781
+ delete childProps.exit;
782
+ delete childProps.timeout;
783
+ delete childProps.addEndListener;
784
+ delete childProps.onEnter;
785
+ delete childProps.onEntering;
786
+ delete childProps.onEntered;
787
+ delete childProps.onExit;
788
+ delete childProps.onExiting;
789
+ delete childProps.onExited;
790
+
791
+ if (typeof children === 'function') {
792
+ return children(status, childProps);
793
+ }
794
+
795
+ var child = _react2.default.Children.only(children);
796
+ return _react2.default.cloneElement(child, childProps);
797
+ };
798
+
799
+ return Transition;
800
+ }(_react2.default.Component);
801
+
802
+ Transition.contextTypes = {
803
+ transitionGroup: PropTypes.object
804
+ };
805
+ Transition.childContextTypes = {
806
+ transitionGroup: function transitionGroup() {}
807
+ };
808
+
809
+
810
+ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
811
+ /**
812
+ * A `function` child can be used instead of a React element.
813
+ * This function is called with the current transition status
814
+ * ('entering', 'entered', 'exiting', 'exited', 'unmounted'), which can used
815
+ * to apply context specific props to a component.
816
+ *
817
+ * ```jsx
818
+ * <Transition timeout={150}>
819
+ * {(status) => (
820
+ * <MyComponent className={`fade fade-${status}`} />
821
+ * )}
822
+ * </Transition>
823
+ * ```
824
+ */
825
+ children: PropTypes.oneOfType([PropTypes.func.isRequired, PropTypes.element.isRequired]).isRequired,
826
+
827
+ /**
828
+ * Show the component; triggers the enter or exit states
829
+ */
830
+ in: PropTypes.bool,
831
+
832
+ /**
833
+ * By default the child component is mounted immediately along with
834
+ * the parent `Transition` component. If you want to "lazy mount" the component on the
835
+ * first `in={true}` you can set `mountOnEnter`. After the first enter transition the component will stay
836
+ * mounted, even on "exited", unless you also specify `unmountOnExit`.
837
+ */
838
+ mountOnEnter: PropTypes.bool,
839
+
840
+ /**
841
+ * By default the child component stays mounted after it reaches the `'exited'` state.
842
+ * Set `unmountOnExit` if you'd prefer to unmount the component after it finishes exiting.
843
+ */
844
+ unmountOnExit: PropTypes.bool,
845
+
846
+ /**
847
+ * Normally a component is not transitioned if it is shown when the `<Transition>` component mounts.
848
+ * If you want to transition on the first mount set `appear` to `true`, and the
849
+ * component will transition in as soon as the `<Transition>` mounts.
850
+ *
851
+ * > Note: there are no specific "appear" states. `appear` only adds an additional `enter` transition.
852
+ */
853
+ appear: PropTypes.bool,
854
+
855
+ /**
856
+ * Enable or disable enter transitions.
857
+ */
858
+ enter: PropTypes.bool,
859
+
860
+ /**
861
+ * Enable or disable exit transitions.
862
+ */
863
+ exit: PropTypes.bool,
864
+
865
+ /**
866
+ * The duration of the transition, in milliseconds.
867
+ * Required unless `addEventListener` is provided
868
+ *
869
+ * You may specify a single timeout for all transitions like: `timeout={500}`,
870
+ * or individually like:
871
+ *
872
+ * ```jsx
873
+ * timeout={{
874
+ * enter: 300,
875
+ * exit: 500,
876
+ * }}
877
+ * ```
878
+ *
879
+ * @type {number | { enter?: number, exit?: number }}
880
+ */
881
+ timeout: function timeout(props) {
882
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
883
+ args[_key - 1] = arguments[_key];
884
+ }
885
+
886
+ var pt = _PropTypes.timeoutsShape;
887
+ if (!props.addEndListener) pt = pt.isRequired;
888
+ return pt.apply(undefined, [props].concat(args));
889
+ },
890
+
891
+ /**
892
+ * Add a custom transition end trigger. Called with the transitioning
893
+ * DOM node and a `done` callback. Allows for more fine grained transition end
894
+ * logic. **Note:** Timeouts are still used as a fallback if provided.
895
+ *
896
+ * ```jsx
897
+ * addEndListener={(node, done) => {
898
+ * // use the css transitionend event to mark the finish of a transition
899
+ * node.addEventListener('transitionend', done, false);
900
+ * }}
901
+ * ```
902
+ */
903
+ addEndListener: PropTypes.func,
904
+
905
+ /**
906
+ * Callback fired before the "entering" status is applied. An extra parameter
907
+ * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
908
+ *
909
+ * @type Function(node: HtmlElement, isAppearing: bool) -> void
910
+ */
911
+ onEnter: PropTypes.func,
912
+
913
+ /**
914
+ * Callback fired after the "entering" status is applied. An extra parameter
915
+ * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
916
+ *
917
+ * @type Function(node: HtmlElement, isAppearing: bool)
918
+ */
919
+ onEntering: PropTypes.func,
920
+
921
+ /**
922
+ * Callback fired after the "entered" status is applied. An extra parameter
923
+ * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
924
+ *
925
+ * @type Function(node: HtmlElement, isAppearing: bool) -> void
926
+ */
927
+ onEntered: PropTypes.func,
928
+
929
+ /**
930
+ * Callback fired before the "exiting" status is applied.
931
+ *
932
+ * @type Function(node: HtmlElement) -> void
933
+ */
934
+ onExit: PropTypes.func,
935
+
936
+ /**
937
+ * Callback fired after the "exiting" status is applied.
938
+ *
939
+ * @type Function(node: HtmlElement) -> void
940
+ */
941
+ onExiting: PropTypes.func,
942
+
943
+ /**
944
+ * Callback fired after the "exited" status is applied.
945
+ *
946
+ * @type Function(node: HtmlElement) -> void
947
+ */
948
+ onExited: PropTypes.func
949
+ } : {};
950
+
951
+ // Name the function so it is clearer in the documentation
952
+ function noop() {}
953
+
954
+ Transition.defaultProps = {
955
+ in: false,
956
+ mountOnEnter: false,
957
+ unmountOnExit: false,
958
+ appear: false,
959
+ enter: true,
960
+ exit: true,
961
+
962
+ onEnter: noop,
963
+ onEntering: noop,
964
+ onEntered: noop,
965
+
966
+ onExit: noop,
967
+ onExiting: noop,
968
+ onExited: noop
969
+ };
970
+
971
+ Transition.UNMOUNTED = 0;
972
+ Transition.EXITED = 1;
973
+ Transition.ENTERING = 2;
974
+ Transition.ENTERED = 3;
975
+ Transition.EXITING = 4;
976
+
977
+ exports.default = Transition;
978
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
979
+
980
+ /***/ }),
981
+ /* 6 */
982
+ /***/ (function(module, exports, __webpack_require__) {
983
+
984
+ "use strict";
985
+ /* WEBPACK VAR INJECTION */(function(process) {/**
986
+ * Copyright (c) 2014-present, Facebook, Inc.
987
+ *
988
+ * This source code is licensed under the MIT license found in the
989
+ * LICENSE file in the root directory of this source tree.
990
+ *
991
+ */
992
+
993
+
994
+
995
+ var emptyFunction = __webpack_require__(3);
996
+
997
+ /**
998
+ * Similar to invariant but only logs a warning if the condition is not met.
999
+ * This can be used to log issues in development environments in critical
1000
+ * paths. Removing the logging code for production environments will keep the
1001
+ * same logic and follow the same code paths.
1002
+ */
1003
+
1004
+ var warning = emptyFunction;
1005
+
1006
+ if (process.env.NODE_ENV !== 'production') {
1007
+ var printWarning = function printWarning(format) {
1008
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1009
+ args[_key - 1] = arguments[_key];
1010
+ }
1011
+
1012
+ var argIndex = 0;
1013
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
1014
+ return args[argIndex++];
1015
+ });
1016
+ if (typeof console !== 'undefined') {
1017
+ console.error(message);
1018
+ }
1019
+ try {
1020
+ // --- Welcome to debugging React ---
1021
+ // This error was thrown as a convenience so that you can use this stack
1022
+ // to find the callsite that caused this warning to fire.
1023
+ throw new Error(message);
1024
+ } catch (x) {}
1025
+ };
1026
+
1027
+ warning = function warning(condition, format) {
1028
+ if (format === undefined) {
1029
+ throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
1030
+ }
1031
+
1032
+ if (format.indexOf('Failed Composite propType: ') === 0) {
1033
+ return; // Ignore CompositeComponent proptype check.
1034
+ }
1035
+
1036
+ if (!condition) {
1037
+ for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
1038
+ args[_key2 - 2] = arguments[_key2];
1039
+ }
1040
+
1041
+ printWarning.apply(undefined, [format].concat(args));
1042
+ }
1043
+ };
1044
+ }
1045
+
1046
+ module.exports = warning;
1047
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
1048
+
1049
+ /***/ }),
1050
+ /* 7 */
1051
+ /***/ (function(module, exports, __webpack_require__) {
1052
+
1053
+ "use strict";
1054
+ /**
1055
+ * Copyright 2013-present, Facebook, Inc.
1056
+ * All rights reserved.
1057
+ *
1058
+ * This source code is licensed under the BSD-style license found in the
1059
+ * LICENSE file in the root directory of this source tree. An additional grant
1060
+ * of patent rights can be found in the PATENTS file in the same directory.
1061
+ */
1062
+
1063
+
1064
+
1065
+ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
1066
+
1067
+ module.exports = ReactPropTypesSecret;
1068
+
1069
+ /***/ }),
1070
+ /* 8 */
1071
+ /***/ (function(module, exports, __webpack_require__) {
1072
+
1073
+ "use strict";
1074
+
1075
+
1076
+ exports.__esModule = true;
1077
+ exports.classNamesShape = exports.timeoutsShape = undefined;
1078
+ exports.transitionTimeout = transitionTimeout;
1079
+
1080
+ var _propTypes = __webpack_require__(1);
1081
+
1082
+ var _propTypes2 = _interopRequireDefault(_propTypes);
1083
+
1084
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1085
+
1086
+ function transitionTimeout(transitionType) {
1087
+ var timeoutPropName = 'transition' + transitionType + 'Timeout';
1088
+ var enabledPropName = 'transition' + transitionType;
1089
+
1090
+ return function (props) {
1091
+ // If the transition is enabled
1092
+ if (props[enabledPropName]) {
1093
+ // If no timeout duration is provided
1094
+ if (props[timeoutPropName] == null) {
1095
+ return new Error(timeoutPropName + ' wasn\'t supplied to CSSTransitionGroup: ' + 'this can cause unreliable animations and won\'t be supported in ' + 'a future version of React. See ' + 'https://fb.me/react-animation-transition-group-timeout for more ' + 'information.');
1096
+
1097
+ // If the duration isn't a number
1098
+ } else if (typeof props[timeoutPropName] !== 'number') {
1099
+ return new Error(timeoutPropName + ' must be a number (in milliseconds)');
1100
+ }
1101
+ }
1102
+
1103
+ return null;
1104
+ };
1105
+ }
1106
+
1107
+ var timeoutsShape = exports.timeoutsShape = _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.shape({
1108
+ enter: _propTypes2.default.number,
1109
+ exit: _propTypes2.default.number
1110
+ }).isRequired]);
1111
+
1112
+ var classNamesShape = exports.classNamesShape = _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.shape({
1113
+ enter: _propTypes2.default.string,
1114
+ exit: _propTypes2.default.string,
1115
+ active: _propTypes2.default.string
1116
+ }), _propTypes2.default.shape({
1117
+ enter: _propTypes2.default.string,
1118
+ enterActive: _propTypes2.default.string,
1119
+ exit: _propTypes2.default.string,
1120
+ exitActive: _propTypes2.default.string
1121
+ })]);
1122
+
1123
+ /***/ }),
1124
+ /* 9 */
1125
+ /***/ (function(module, exports, __webpack_require__) {
1126
+
1127
+ "use strict";
1128
+ /* WEBPACK VAR INJECTION */(function(process) {
1129
+
1130
+ exports.__esModule = true;
1131
+
1132
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
1133
+
1134
+ var _propTypes = __webpack_require__(1);
1135
+
1136
+ var PropTypes = _interopRequireWildcard(_propTypes);
1137
+
1138
+ var _addClass = __webpack_require__(11);
1139
+
1140
+ var _addClass2 = _interopRequireDefault(_addClass);
1141
+
1142
+ var _removeClass = __webpack_require__(13);
1143
+
1144
+ var _removeClass2 = _interopRequireDefault(_removeClass);
1145
+
1146
+ var _react = __webpack_require__(2);
1147
+
1148
+ var _react2 = _interopRequireDefault(_react);
1149
+
1150
+ var _Transition = __webpack_require__(5);
1151
+
1152
+ var _Transition2 = _interopRequireDefault(_Transition);
1153
+
1154
+ var _PropTypes = __webpack_require__(8);
1155
+
1156
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1157
+
1158
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
1159
+
1160
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1161
+
1162
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
1163
+
1164
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
1165
+
1166
+ var addClass = function addClass(node, classes) {
1167
+ return classes && classes.split(' ').forEach(function (c) {
1168
+ return (0, _addClass2.default)(node, c);
1169
+ });
1170
+ };
1171
+ var removeClass = function removeClass(node, classes) {
1172
+ return classes && classes.split(' ').forEach(function (c) {
1173
+ return (0, _removeClass2.default)(node, c);
1174
+ });
1175
+ };
1176
+
1177
+ var propTypes = _extends({}, _Transition2.default.propTypes, {
1178
+
1179
+ /**
1180
+ * The animation classNames applied to the component as it enters or exits.
1181
+ * A single name can be provided and it will be suffixed for each stage: e.g.
1182
+ *
1183
+ * `classNames="fade"` applies `fade-enter`, `fade-enter-active`,
1184
+ * `fade-exit`, `fade-exit-active`, `fade-appear`, and `fade-appear-active`.
1185
+ * Each individual classNames can also be specified independently like:
1186
+ *
1187
+ * ```js
1188
+ * classNames={{
1189
+ * appear: 'my-appear',
1190
+ * appearActive: 'my-active-appear',
1191
+ * enter: 'my-enter',
1192
+ * enterActive: 'my-active-enter',
1193
+ * exit: 'my-exit',
1194
+ * exitActive: 'my-active-exit',
1195
+ * }}
1196
+ * ```
1197
+ *
1198
+ * @type {string | {
1199
+ * appear?: string,
1200
+ * appearActive?: string,
1201
+ * enter?: string,
1202
+ * enterActive?: string,
1203
+ * exit?: string,
1204
+ * exitActive?: string,
1205
+ * }}
1206
+ */
1207
+ classNames: _PropTypes.classNamesShape,
1208
+
1209
+ /**
1210
+ * A `<Transition>` callback fired immediately after the 'enter' or 'appear' class is
1211
+ * applied.
1212
+ *
1213
+ * @type Function(node: HtmlElement, isAppearing: bool)
1214
+ */
1215
+ onEnter: PropTypes.func,
1216
+
1217
+ /**
1218
+ * A `<Transition>` callback fired immediately after the 'enter-active' or
1219
+ * 'appear-active' class is applied.
1220
+ *
1221
+ * @type Function(node: HtmlElement, isAppearing: bool)
1222
+ */
1223
+ onEntering: PropTypes.func,
1224
+
1225
+ /**
1226
+ * A `<Transition>` callback fired immediately after the 'enter' or
1227
+ * 'appear' classes are **removed** from the DOM node.
1228
+ *
1229
+ * @type Function(node: HtmlElement, isAppearing: bool)
1230
+ */
1231
+ onEntered: PropTypes.func,
1232
+
1233
+ /**
1234
+ * A `<Transition>` callback fired immediately after the 'exit' class is
1235
+ * applied.
1236
+ *
1237
+ * @type Function(node: HtmlElement)
1238
+ */
1239
+ onExit: PropTypes.func,
1240
+
1241
+ /**
1242
+ * A `<Transition>` callback fired immediately after the 'exit-active' is applied.
1243
+ *
1244
+ * @type Function(node: HtmlElement
1245
+ */
1246
+ onExiting: PropTypes.func,
1247
+
1248
+ /**
1249
+ * A `<Transition>` callback fired immediately after the 'exit' classes
1250
+ * are **removed** from the DOM node.
1251
+ *
1252
+ * @type Function(node: HtmlElement)
1253
+ */
1254
+ onExited: PropTypes.func
1255
+ });
1256
+
1257
+ /**
1258
+ * A `Transition` component using CSS transitions and animations.
1259
+ * It's inspired by the excellent [ng-animate](http://www.nganimate.org/) library.
1260
+ *
1261
+ * `CSSTransition` applies a pair of class names during the `appear`, `enter`,
1262
+ * and `exit` stages of the transition. The first class is applied and then a
1263
+ * second "active" class in order to activate the css animation.
1264
+ *
1265
+ * When the `in` prop is toggled to `true` the Component will get
1266
+ * the `example-enter` CSS class and the `example-enter-active` CSS class
1267
+ * added in the next tick. This is a convention based on the `classNames` prop.
1268
+ *
1269
+ * ```js
1270
+ * import CSSTransition from 'react-transition-group/CSSTransition';
1271
+ *
1272
+ * const Fade = ({ children, ...props }) => (
1273
+ * <CSSTransition
1274
+ * {...props}
1275
+ * timeout={500}
1276
+ * classNames="fade"
1277
+ * >
1278
+ * {children}
1279
+ * </CSSTransition>
1280
+ * );
1281
+ *
1282
+ * class FadeInAndOut extends React.Component {
1283
+ * constructor(...args) {
1284
+ * super(...args);
1285
+ * this.state= { show: false }
1286
+ *
1287
+ * setInterval(() => {
1288
+ * this.setState({ show: !this.state.show })
1289
+ * }, 5000)
1290
+ * }
1291
+ * render() {
1292
+ * return (
1293
+ * <Fade in={this.state.show}>
1294
+ * <div>Hello world</div>
1295
+ * </Fade>
1296
+ * )
1297
+ * }
1298
+ * }
1299
+ * ```
1300
+ *
1301
+ * And the coorresponding CSS for the `<Fade>` component:
1302
+ *
1303
+ * ```css
1304
+ * .fade-enter {
1305
+ * opacity: 0.01;
1306
+ * }
1307
+ *
1308
+ * .fade-enter.fade-enter-active {
1309
+ * opacity: 1;
1310
+ * transition: opacity 500ms ease-in;
1311
+ * }
1312
+ *
1313
+ * .fade-exit {
1314
+ * opacity: 1;
1315
+ * }
1316
+ *
1317
+ * .fade-exit.fade-exit-active {
1318
+ * opacity: 0.01;
1319
+ * transition: opacity 300ms ease-in;
1320
+ * }
1321
+ * ```
1322
+ */
1323
+
1324
+ var CSSTransition = function (_React$Component) {
1325
+ _inherits(CSSTransition, _React$Component);
1326
+
1327
+ function CSSTransition() {
1328
+ var _temp, _this, _ret;
1329
+
1330
+ _classCallCheck(this, CSSTransition);
1331
+
1332
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
1333
+ args[_key] = arguments[_key];
1334
+ }
1335
+
1336
+ return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.onEnter = function (node, appearing) {
1337
+ var _this$getClassNames = _this.getClassNames(appearing ? 'appear' : 'enter'),
1338
+ className = _this$getClassNames.className;
1339
+
1340
+ _this.removeClasses(node, 'exit');
1341
+ addClass(node, className);
1342
+
1343
+ if (_this.props.onEnter) {
1344
+ _this.props.onEnter(node);
1345
+ }
1346
+ }, _this.onEntering = function (node, appearing) {
1347
+ var _this$getClassNames2 = _this.getClassNames(appearing ? 'appear' : 'enter'),
1348
+ activeClassName = _this$getClassNames2.activeClassName;
1349
+
1350
+ _this.reflowAndAddClass(node, activeClassName);
1351
+
1352
+ if (_this.props.onEntering) {
1353
+ _this.props.onEntering(node);
1354
+ }
1355
+ }, _this.onEntered = function (node, appearing) {
1356
+ _this.removeClasses(node, appearing ? 'appear' : 'enter');
1357
+
1358
+ if (_this.props.onEntered) {
1359
+ _this.props.onEntered(node);
1360
+ }
1361
+ }, _this.onExit = function (node) {
1362
+ var _this$getClassNames3 = _this.getClassNames('exit'),
1363
+ className = _this$getClassNames3.className;
1364
+
1365
+ _this.removeClasses(node, 'appear');
1366
+ _this.removeClasses(node, 'enter');
1367
+ addClass(node, className);
1368
+
1369
+ if (_this.props.onExit) {
1370
+ _this.props.onExit(node);
1371
+ }
1372
+ }, _this.onExiting = function (node) {
1373
+ var _this$getClassNames4 = _this.getClassNames('exit'),
1374
+ activeClassName = _this$getClassNames4.activeClassName;
1375
+
1376
+ _this.reflowAndAddClass(node, activeClassName);
1377
+
1378
+ if (_this.props.onExiting) {
1379
+ _this.props.onExiting(node);
1380
+ }
1381
+ }, _this.onExited = function (node) {
1382
+ _this.removeClasses(node, 'exit');
1383
+
1384
+ if (_this.props.onExited) {
1385
+ _this.props.onExited(node);
1386
+ }
1387
+ }, _this.getClassNames = function (type) {
1388
+ var classNames = _this.props.classNames;
1389
+
1390
+
1391
+ var className = typeof classNames !== 'string' ? classNames[type] : classNames + '-' + type;
1392
+
1393
+ var activeClassName = typeof classNames !== 'string' ? classNames[type + 'Active'] : className + '-active';
1394
+
1395
+ return { className: className, activeClassName: activeClassName };
1396
+ }, _temp), _possibleConstructorReturn(_this, _ret);
1397
+ }
1398
+
1399
+ CSSTransition.prototype.removeClasses = function removeClasses(node, type) {
1400
+ var _getClassNames = this.getClassNames(type),
1401
+ className = _getClassNames.className,
1402
+ activeClassName = _getClassNames.activeClassName;
1403
+
1404
+ className && removeClass(node, className);
1405
+ activeClassName && removeClass(node, activeClassName);
1406
+ };
1407
+
1408
+ CSSTransition.prototype.reflowAndAddClass = function reflowAndAddClass(node, className) {
1409
+ // This is for to force a repaint,
1410
+ // which is necessary in order to transition styles when adding a class name.
1411
+ /* eslint-disable no-unused-expressions */
1412
+ node.scrollTop;
1413
+ /* eslint-enable no-unused-expressions */
1414
+ addClass(node, className);
1415
+ };
1416
+
1417
+ CSSTransition.prototype.render = function render() {
1418
+ var props = _extends({}, this.props);
1419
+
1420
+ delete props.classNames;
1421
+
1422
+ return _react2.default.createElement(_Transition2.default, _extends({}, props, {
1423
+ onEnter: this.onEnter,
1424
+ onEntered: this.onEntered,
1425
+ onEntering: this.onEntering,
1426
+ onExit: this.onExit,
1427
+ onExiting: this.onExiting,
1428
+ onExited: this.onExited
1429
+ }));
1430
+ };
1431
+
1432
+ return CSSTransition;
1433
+ }(_react2.default.Component);
1434
+
1435
+ CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
1436
+
1437
+ exports.default = CSSTransition;
1438
+ module.exports = exports['default'];
1439
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
1440
+
1441
+ /***/ }),
1442
+ /* 10 */
1443
+ /***/ (function(module, exports, __webpack_require__) {
1444
+
1445
+ "use strict";
1446
+ /* WEBPACK VAR INJECTION */(function(process) {
1447
+
1448
+ exports.__esModule = true;
1449
+
1450
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
1451
+
1452
+ var _propTypes = __webpack_require__(1);
1453
+
1454
+ var _propTypes2 = _interopRequireDefault(_propTypes);
1455
+
1456
+ var _react = __webpack_require__(2);
1457
+
1458
+ var _react2 = _interopRequireDefault(_react);
1459
+
1460
+ var _ChildMapping = __webpack_require__(18);
1461
+
1462
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1463
+
1464
+ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
1465
+
1466
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1467
+
1468
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
1469
+
1470
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
1471
+
1472
+ var values = Object.values || function (obj) {
1473
+ return Object.keys(obj).map(function (k) {
1474
+ return obj[k];
1475
+ });
1476
+ };
1477
+
1478
+ var propTypes = {
1479
+ /**
1480
+ * `<TransitionGroup>` renders a `<div>` by default. You can change this
1481
+ * behavior by providing a `component` prop.
1482
+ */
1483
+ component: _propTypes2.default.any,
1484
+ /**
1485
+ * A set of `<Transition>` components, that are toggled `in` and out as they
1486
+ * leave. the `<TransitionGroup>` will inject specific transition props, so
1487
+ * remember to spread them through if you are wrapping the `<Transition>` as
1488
+ * with our `<Fade>` example.
1489
+ */
1490
+ children: _propTypes2.default.node,
1491
+
1492
+ /**
1493
+ * A convenience prop that enables or disabled appear animations
1494
+ * for all children. Note that specifying this will override any defaults set
1495
+ * on individual children Transitions.
1496
+ */
1497
+ appear: _propTypes2.default.bool,
1498
+ /**
1499
+ * A convenience prop that enables or disabled enter animations
1500
+ * for all children. Note that specifying this will override any defaults set
1501
+ * on individual children Transitions.
1502
+ */
1503
+ enter: _propTypes2.default.bool,
1504
+ /**
1505
+ * A convenience prop that enables or disabled exit animations
1506
+ * for all children. Note that specifying this will override any defaults set
1507
+ * on individual children Transitions.
1508
+ */
1509
+ exit: _propTypes2.default.bool,
1510
+
1511
+ /**
1512
+ * You may need to apply reactive updates to a child as it is exiting.
1513
+ * This is generally done by using `cloneElement` however in the case of an exiting
1514
+ * child the element has already been removed and not accessible to the consumer.
1515
+ *
1516
+ * If you do need to update a child as it leaves you can provide a `childFactory`
1517
+ * to wrap every child, even the ones that are leaving.
1518
+ *
1519
+ * @type Function(child: ReactElement) -> ReactElement
1520
+ */
1521
+ childFactory: _propTypes2.default.func
1522
+ };
1523
+
1524
+ var defaultProps = {
1525
+ component: 'div',
1526
+ childFactory: function childFactory(child) {
1527
+ return child;
1528
+ }
1529
+ };
1530
+
1531
+ /**
1532
+ * The `<TransitionGroup>` component manages a set of `<Transition>` components
1533
+ * in a list. Like with the `<Transition>` component, `<TransitionGroup>`, is a
1534
+ * state machine for managing the mounting and unmounting of components over
1535
+ * time.
1536
+ *
1537
+ * Consider the example below using the `Fade` CSS transition from before.
1538
+ * As items are removed or added to the TodoList the `in` prop is toggled
1539
+ * automatically by the `<TransitionGroup>`. You can use _any_ `<Transition>`
1540
+ * component in a `<TransitionGroup>`, not just css.
1541
+ *
1542
+ * ```jsx
1543
+ * import TransitionGroup from 'react-transition-group/TransitionGroup';
1544
+ *
1545
+ * class TodoList extends React.Component {
1546
+ * constructor(props) {
1547
+ * super(props)
1548
+ * this.state = {items: ['hello', 'world', 'click', 'me']}
1549
+ * }
1550
+ * handleAdd() {
1551
+ * const newItems = this.state.items.concat([
1552
+ * prompt('Enter some text')
1553
+ * ]);
1554
+ * this.setState({ items: newItems });
1555
+ * }
1556
+ * handleRemove(i) {
1557
+ * let newItems = this.state.items.slice();
1558
+ * newItems.splice(i, 1);
1559
+ * this.setState({items: newItems});
1560
+ * }
1561
+ * render() {
1562
+ * return (
1563
+ * <div>
1564
+ * <button onClick={() => this.handleAdd()}>Add Item</button>
1565
+ * <TransitionGroup>
1566
+ * {this.state.items.map((item, i) => (
1567
+ * <FadeTransition key={item}>
1568
+ * <div>
1569
+ * {item}{' '}
1570
+ * <button onClick={() => this.handleRemove(i)}>
1571
+ * remove
1572
+ * </button>
1573
+ * </div>
1574
+ * </FadeTransition>
1575
+ * ))}
1576
+ * </TransitionGroup>
1577
+ * </div>
1578
+ * );
1579
+ * }
1580
+ * }
1581
+ * ```
1582
+ *
1583
+ * Note that `<TransitionGroup>` does not define any animation behavior!
1584
+ * Exactly _how_ a list item animates is up to the individual `<Transition>`
1585
+ * components. This means you can mix and match animations across different
1586
+ * list items.
1587
+ */
1588
+
1589
+ var TransitionGroup = function (_React$Component) {
1590
+ _inherits(TransitionGroup, _React$Component);
1591
+
1592
+ function TransitionGroup(props, context) {
1593
+ _classCallCheck(this, TransitionGroup);
1594
+
1595
+ // Initial children should all be entering, dependent on appear
1596
+ var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context));
1597
+
1598
+ _this.handleExited = function (key, node, originalHandler) {
1599
+ var currentChildMapping = (0, _ChildMapping.getChildMapping)(_this.props.children);
1600
+
1601
+ if (key in currentChildMapping) return;
1602
+
1603
+ if (originalHandler) originalHandler(node);
1604
+
1605
+ _this.setState(function (state) {
1606
+ var children = _extends({}, state.children);
1607
+
1608
+ delete children[key];
1609
+ return { children: children };
1610
+ });
1611
+ };
1612
+
1613
+ _this.state = {
1614
+ children: (0, _ChildMapping.getChildMapping)(props.children, function (child) {
1615
+ var onExited = function onExited(node) {
1616
+ _this.handleExited(child.key, node, child.props.onExited);
1617
+ };
1618
+
1619
+ return (0, _react.cloneElement)(child, {
1620
+ onExited: onExited,
1621
+ in: true,
1622
+ appear: _this.getProp(child, 'appear'),
1623
+ enter: _this.getProp(child, 'enter'),
1624
+ exit: _this.getProp(child, 'exit')
1625
+ });
1626
+ })
1627
+ };
1628
+ return _this;
1629
+ }
1630
+
1631
+ TransitionGroup.prototype.getChildContext = function getChildContext() {
1632
+ return {
1633
+ transitionGroup: { isMounting: !this.appeared }
1634
+ };
1635
+ };
1636
+ // use child config unless explictly set by the Group
1637
+
1638
+
1639
+ TransitionGroup.prototype.getProp = function getProp(child, prop) {
1640
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.props;
1641
+
1642
+ return props[prop] != null ? props[prop] : child.props[prop];
1643
+ };
1644
+
1645
+ TransitionGroup.prototype.componentDidMount = function componentDidMount() {
1646
+ this.appeared = true;
1647
+ };
1648
+
1649
+ TransitionGroup.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
1650
+ var _this2 = this;
1651
+
1652
+ var prevChildMapping = this.state.children;
1653
+ var nextChildMapping = (0, _ChildMapping.getChildMapping)(nextProps.children);
1654
+
1655
+ var children = (0, _ChildMapping.mergeChildMappings)(prevChildMapping, nextChildMapping);
1656
+
1657
+ Object.keys(children).forEach(function (key) {
1658
+ var child = children[key];
1659
+
1660
+ if (!(0, _react.isValidElement)(child)) return;
1661
+
1662
+ var onExited = function onExited(node) {
1663
+ _this2.handleExited(child.key, node, child.props.onExited);
1664
+ };
1665
+
1666
+ var hasPrev = key in prevChildMapping;
1667
+ var hasNext = key in nextChildMapping;
1668
+
1669
+ var prevChild = prevChildMapping[key];
1670
+ var isLeaving = (0, _react.isValidElement)(prevChild) && !prevChild.props.in;
1671
+
1672
+ // item is new (entering)
1673
+ if (hasNext && (!hasPrev || isLeaving)) {
1674
+ // console.log('entering', key)
1675
+ children[key] = (0, _react.cloneElement)(child, {
1676
+ onExited: onExited,
1677
+ in: true,
1678
+ exit: _this2.getProp(child, 'exit', nextProps),
1679
+ enter: _this2.getProp(child, 'enter', nextProps)
1680
+ });
1681
+ }
1682
+ // item is old (exiting)
1683
+ else if (!hasNext && hasPrev && !isLeaving) {
1684
+ // console.log('leaving', key)
1685
+ children[key] = (0, _react.cloneElement)(child, { in: false });
1686
+ }
1687
+ // item hasn't changed transition states
1688
+ // copy over the last transition props;
1689
+ else if (hasNext && hasPrev && (0, _react.isValidElement)(prevChild)) {
1690
+ // console.log('unchanged', key)
1691
+ children[key] = (0, _react.cloneElement)(child, {
1692
+ onExited: onExited,
1693
+ in: prevChild.props.in,
1694
+ exit: _this2.getProp(child, 'exit', nextProps),
1695
+ enter: _this2.getProp(child, 'enter', nextProps)
1696
+ });
1697
+ }
1698
+ });
1699
+
1700
+ this.setState({ children: children });
1701
+ };
1702
+
1703
+ TransitionGroup.prototype.render = function render() {
1704
+ var _props = this.props,
1705
+ Component = _props.component,
1706
+ childFactory = _props.childFactory,
1707
+ props = _objectWithoutProperties(_props, ['component', 'childFactory']);
1708
+
1709
+ var children = this.state.children;
1710
+
1711
+
1712
+ delete props.appear;
1713
+ delete props.enter;
1714
+ delete props.exit;
1715
+
1716
+ return _react2.default.createElement(
1717
+ Component,
1718
+ props,
1719
+ values(children).map(childFactory)
1720
+ );
1721
+ };
1722
+
1723
+ return TransitionGroup;
1724
+ }(_react2.default.Component);
1725
+
1726
+ TransitionGroup.childContextTypes = {
1727
+ transitionGroup: _propTypes2.default.object.isRequired
1728
+ };
1729
+
1730
+
1731
+ TransitionGroup.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
1732
+ TransitionGroup.defaultProps = defaultProps;
1733
+
1734
+ exports.default = TransitionGroup;
1735
+ module.exports = exports['default'];
1736
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
1737
+
1738
+ /***/ }),
1739
+ /* 11 */
1740
+ /***/ (function(module, exports, __webpack_require__) {
1741
+
1742
+ "use strict";
1743
+
1744
+
1745
+ Object.defineProperty(exports, "__esModule", {
1746
+ value: true
1747
+ });
1748
+ exports.default = addClass;
1749
+
1750
+ var _hasClass = __webpack_require__(12);
1751
+
1752
+ var _hasClass2 = _interopRequireDefault(_hasClass);
1753
+
1754
+ function _interopRequireDefault(obj) {
1755
+ return obj && obj.__esModule ? obj : { default: obj };
1756
+ }
1757
+
1758
+ function addClass(element, className) {
1759
+ if (element.classList) element.classList.add(className);else if (!(0, _hasClass2.default)(element)) element.className = element.className + ' ' + className;
1760
+ }
1761
+ module.exports = exports['default'];
1762
+
1763
+ /***/ }),
1764
+ /* 12 */
1765
+ /***/ (function(module, exports, __webpack_require__) {
1766
+
1767
+ "use strict";
1768
+
1769
+
1770
+ Object.defineProperty(exports, "__esModule", {
1771
+ value: true
1772
+ });
1773
+ exports.default = hasClass;
1774
+ function hasClass(element, className) {
1775
+ if (element.classList) return !!className && element.classList.contains(className);else return (" " + element.className + " ").indexOf(" " + className + " ") !== -1;
1776
+ }
1777
+ module.exports = exports["default"];
1778
+
1779
+ /***/ }),
1780
+ /* 13 */
1781
+ /***/ (function(module, exports, __webpack_require__) {
1782
+
1783
+ "use strict";
1784
+
1785
+
1786
+ module.exports = function removeClass(element, className) {
1787
+ if (element.classList) element.classList.remove(className);else element.className = element.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1').replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, '');
1788
+ };
1789
+
1790
+ /***/ }),
1791
+ /* 14 */
1792
+ /***/ (function(module, exports, __webpack_require__) {
1793
+
1794
+ "use strict";
1795
+ /* WEBPACK VAR INJECTION */(function(process) {/**
1796
+ * Copyright 2013-present, Facebook, Inc.
1797
+ * All rights reserved.
1798
+ *
1799
+ * This source code is licensed under the BSD-style license found in the
1800
+ * LICENSE file in the root directory of this source tree. An additional grant
1801
+ * of patent rights can be found in the PATENTS file in the same directory.
1802
+ */
1803
+
1804
+
1805
+
1806
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
1807
+
1808
+ if (process.env.NODE_ENV !== 'production') {
1809
+ var invariant = __webpack_require__(4);
1810
+ var warning = __webpack_require__(6);
1811
+ var ReactPropTypesSecret = __webpack_require__(7);
1812
+ var loggedTypeFailures = {};
1813
+ }
1814
+
1815
+ /**
1816
+ * Assert that the values match with the type specs.
1817
+ * Error messages are memorized and will only be shown once.
1818
+ *
1819
+ * @param {object} typeSpecs Map of name to a ReactPropType
1820
+ * @param {object} values Runtime values that need to be type-checked
1821
+ * @param {string} location e.g. "prop", "context", "child context"
1822
+ * @param {string} componentName Name of the component for error messages.
1823
+ * @param {?Function} getStack Returns the component stack.
1824
+ * @private
1825
+ */
1826
+ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
1827
+ if (process.env.NODE_ENV !== 'production') {
1828
+ for (var typeSpecName in typeSpecs) {
1829
+ if (typeSpecs.hasOwnProperty(typeSpecName)) {
1830
+ var error;
1831
+ // Prop type validation may throw. In case they do, we don't want to
1832
+ // fail the render phase where it didn't fail before. So we log it.
1833
+ // After these have been cleaned up, we'll let them throw.
1834
+ try {
1835
+ // This is intentionally an invariant that gets caught. It's the same
1836
+ // behavior as without this statement except with a better message.
1837
+ !(typeof typeSpecs[typeSpecName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName) : invariant(false) : void 0;
1838
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
1839
+ } catch (ex) {
1840
+ error = ex;
1841
+ }
1842
+ process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error === 'undefined' ? 'undefined' : _typeof(error)) : void 0;
1843
+ if (error instanceof Error && !(error.message in loggedTypeFailures)) {
1844
+ // Only monitor this failure once because there tends to be a lot of the
1845
+ // same error.
1846
+ loggedTypeFailures[error.message] = true;
1847
+
1848
+ var stack = getStack ? getStack() : '';
1849
+
1850
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '') : void 0;
1851
+ }
1852
+ }
1853
+ }
1854
+ }
1855
+ }
1856
+
1857
+ module.exports = checkPropTypes;
1858
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
1859
+
1860
+ /***/ }),
1861
+ /* 15 */
1862
+ /***/ (function(module, exports, __webpack_require__) {
1863
+
1864
+ "use strict";
1865
+ /* WEBPACK VAR INJECTION */(function(process) {/**
1866
+ * Copyright 2013-present, Facebook, Inc.
1867
+ * All rights reserved.
1868
+ *
1869
+ * This source code is licensed under the BSD-style license found in the
1870
+ * LICENSE file in the root directory of this source tree. An additional grant
1871
+ * of patent rights can be found in the PATENTS file in the same directory.
1872
+ */
1873
+
1874
+
1875
+
1876
+ var emptyFunction = __webpack_require__(3);
1877
+ var invariant = __webpack_require__(4);
1878
+
1879
+ module.exports = function () {
1880
+ // Important!
1881
+ // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
1882
+ function shim() {
1883
+ true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types') : invariant(false) : void 0;
1884
+ };
1885
+ shim.isRequired = shim;
1886
+ function getShim() {
1887
+ return shim;
1888
+ };
1889
+ var ReactPropTypes = {
1890
+ array: shim,
1891
+ bool: shim,
1892
+ func: shim,
1893
+ number: shim,
1894
+ object: shim,
1895
+ string: shim,
1896
+ symbol: shim,
1897
+
1898
+ any: shim,
1899
+ arrayOf: getShim,
1900
+ element: shim,
1901
+ instanceOf: getShim,
1902
+ node: shim,
1903
+ objectOf: getShim,
1904
+ oneOf: getShim,
1905
+ oneOfType: getShim,
1906
+ shape: getShim
1907
+ };
1908
+
1909
+ ReactPropTypes.checkPropTypes = emptyFunction;
1910
+ ReactPropTypes.PropTypes = ReactPropTypes;
1911
+
1912
+ return ReactPropTypes;
1913
+ };
1914
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
1915
+
1916
+ /***/ }),
1917
+ /* 16 */
1918
+ /***/ (function(module, exports, __webpack_require__) {
1919
+
1920
+ "use strict";
1921
+ /* WEBPACK VAR INJECTION */(function(process) {/**
1922
+ * Copyright 2013-present, Facebook, Inc.
1923
+ * All rights reserved.
1924
+ *
1925
+ * This source code is licensed under the BSD-style license found in the
1926
+ * LICENSE file in the root directory of this source tree. An additional grant
1927
+ * of patent rights can be found in the PATENTS file in the same directory.
1928
+ */
1929
+
1930
+
1931
+
1932
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
1933
+
1934
+ var emptyFunction = __webpack_require__(3);
1935
+ var invariant = __webpack_require__(4);
1936
+ var warning = __webpack_require__(6);
1937
+
1938
+ var ReactPropTypesSecret = __webpack_require__(7);
1939
+ var checkPropTypes = __webpack_require__(14);
1940
+
1941
+ module.exports = function (isValidElement, throwOnDirectAccess) {
1942
+ /* global Symbol */
1943
+ var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
1944
+ var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
1945
+
1946
+ /**
1947
+ * Returns the iterator method function contained on the iterable object.
1948
+ *
1949
+ * Be sure to invoke the function with the iterable as context:
1950
+ *
1951
+ * var iteratorFn = getIteratorFn(myIterable);
1952
+ * if (iteratorFn) {
1953
+ * var iterator = iteratorFn.call(myIterable);
1954
+ * ...
1955
+ * }
1956
+ *
1957
+ * @param {?object} maybeIterable
1958
+ * @return {?function}
1959
+ */
1960
+ function getIteratorFn(maybeIterable) {
1961
+ var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
1962
+ if (typeof iteratorFn === 'function') {
1963
+ return iteratorFn;
1964
+ }
1965
+ }
1966
+
1967
+ /**
1968
+ * Collection of methods that allow declaration and validation of props that are
1969
+ * supplied to React components. Example usage:
1970
+ *
1971
+ * var Props = require('ReactPropTypes');
1972
+ * var MyArticle = React.createClass({
1973
+ * propTypes: {
1974
+ * // An optional string prop named "description".
1975
+ * description: Props.string,
1976
+ *
1977
+ * // A required enum prop named "category".
1978
+ * category: Props.oneOf(['News','Photos']).isRequired,
1979
+ *
1980
+ * // A prop named "dialog" that requires an instance of Dialog.
1981
+ * dialog: Props.instanceOf(Dialog).isRequired
1982
+ * },
1983
+ * render: function() { ... }
1984
+ * });
1985
+ *
1986
+ * A more formal specification of how these methods are used:
1987
+ *
1988
+ * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
1989
+ * decl := ReactPropTypes.{type}(.isRequired)?
1990
+ *
1991
+ * Each and every declaration produces a function with the same signature. This
1992
+ * allows the creation of custom validation functions. For example:
1993
+ *
1994
+ * var MyLink = React.createClass({
1995
+ * propTypes: {
1996
+ * // An optional string or URI prop named "href".
1997
+ * href: function(props, propName, componentName) {
1998
+ * var propValue = props[propName];
1999
+ * if (propValue != null && typeof propValue !== 'string' &&
2000
+ * !(propValue instanceof URI)) {
2001
+ * return new Error(
2002
+ * 'Expected a string or an URI for ' + propName + ' in ' +
2003
+ * componentName
2004
+ * );
2005
+ * }
2006
+ * }
2007
+ * },
2008
+ * render: function() {...}
2009
+ * });
2010
+ *
2011
+ * @internal
2012
+ */
2013
+
2014
+ var ANONYMOUS = '<<anonymous>>';
2015
+
2016
+ // Important!
2017
+ // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
2018
+ var ReactPropTypes = {
2019
+ array: createPrimitiveTypeChecker('array'),
2020
+ bool: createPrimitiveTypeChecker('boolean'),
2021
+ func: createPrimitiveTypeChecker('function'),
2022
+ number: createPrimitiveTypeChecker('number'),
2023
+ object: createPrimitiveTypeChecker('object'),
2024
+ string: createPrimitiveTypeChecker('string'),
2025
+ symbol: createPrimitiveTypeChecker('symbol'),
2026
+
2027
+ any: createAnyTypeChecker(),
2028
+ arrayOf: createArrayOfTypeChecker,
2029
+ element: createElementTypeChecker(),
2030
+ instanceOf: createInstanceTypeChecker,
2031
+ node: createNodeChecker(),
2032
+ objectOf: createObjectOfTypeChecker,
2033
+ oneOf: createEnumTypeChecker,
2034
+ oneOfType: createUnionTypeChecker,
2035
+ shape: createShapeTypeChecker
2036
+ };
2037
+
2038
+ /**
2039
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
2040
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
2041
+ */
2042
+ /*eslint-disable no-self-compare*/
2043
+ function is(x, y) {
2044
+ // SameValue algorithm
2045
+ if (x === y) {
2046
+ // Steps 1-5, 7-10
2047
+ // Steps 6.b-6.e: +0 != -0
2048
+ return x !== 0 || 1 / x === 1 / y;
2049
+ } else {
2050
+ // Step 6.a: NaN == NaN
2051
+ return x !== x && y !== y;
2052
+ }
2053
+ }
2054
+ /*eslint-enable no-self-compare*/
2055
+
2056
+ /**
2057
+ * We use an Error-like object for backward compatibility as people may call
2058
+ * PropTypes directly and inspect their output. However, we don't use real
2059
+ * Errors anymore. We don't inspect their stack anyway, and creating them
2060
+ * is prohibitively expensive if they are created too often, such as what
2061
+ * happens in oneOfType() for any type before the one that matched.
2062
+ */
2063
+ function PropTypeError(message) {
2064
+ this.message = message;
2065
+ this.stack = '';
2066
+ }
2067
+ // Make `instanceof Error` still work for returned errors.
2068
+ PropTypeError.prototype = Error.prototype;
2069
+
2070
+ function createChainableTypeChecker(validate) {
2071
+ if (process.env.NODE_ENV !== 'production') {
2072
+ var manualPropTypeCallCache = {};
2073
+ var manualPropTypeWarningCount = 0;
2074
+ }
2075
+ function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
2076
+ componentName = componentName || ANONYMOUS;
2077
+ propFullName = propFullName || propName;
2078
+
2079
+ if (secret !== ReactPropTypesSecret) {
2080
+ if (throwOnDirectAccess) {
2081
+ // New behavior only for users of `prop-types` package
2082
+ true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types') : invariant(false) : void 0;
2083
+ } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
2084
+ // Old behavior for people using React.PropTypes
2085
+ var cacheKey = componentName + ':' + propName;
2086
+ if (!manualPropTypeCallCache[cacheKey] &&
2087
+ // Avoid spamming the console because they are often not actionable except for lib authors
2088
+ manualPropTypeWarningCount < 3) {
2089
+ process.env.NODE_ENV !== 'production' ? warning(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName) : void 0;
2090
+ manualPropTypeCallCache[cacheKey] = true;
2091
+ manualPropTypeWarningCount++;
2092
+ }
2093
+ }
2094
+ }
2095
+ if (props[propName] == null) {
2096
+ if (isRequired) {
2097
+ if (props[propName] === null) {
2098
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
2099
+ }
2100
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
2101
+ }
2102
+ return null;
2103
+ } else {
2104
+ return validate(props, propName, componentName, location, propFullName);
2105
+ }
2106
+ }
2107
+
2108
+ var chainedCheckType = checkType.bind(null, false);
2109
+ chainedCheckType.isRequired = checkType.bind(null, true);
2110
+
2111
+ return chainedCheckType;
2112
+ }
2113
+
2114
+ function createPrimitiveTypeChecker(expectedType) {
2115
+ function validate(props, propName, componentName, location, propFullName, secret) {
2116
+ var propValue = props[propName];
2117
+ var propType = getPropType(propValue);
2118
+ if (propType !== expectedType) {
2119
+ // `propValue` being instance of, say, date/regexp, pass the 'object'
2120
+ // check, but we can offer a more precise error message here rather than
2121
+ // 'of type `object`'.
2122
+ var preciseType = getPreciseType(propValue);
2123
+
2124
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
2125
+ }
2126
+ return null;
2127
+ }
2128
+ return createChainableTypeChecker(validate);
2129
+ }
2130
+
2131
+ function createAnyTypeChecker() {
2132
+ return createChainableTypeChecker(emptyFunction.thatReturnsNull);
2133
+ }
2134
+
2135
+ function createArrayOfTypeChecker(typeChecker) {
2136
+ function validate(props, propName, componentName, location, propFullName) {
2137
+ if (typeof typeChecker !== 'function') {
2138
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
2139
+ }
2140
+ var propValue = props[propName];
2141
+ if (!Array.isArray(propValue)) {
2142
+ var propType = getPropType(propValue);
2143
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
2144
+ }
2145
+ for (var i = 0; i < propValue.length; i++) {
2146
+ var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
2147
+ if (error instanceof Error) {
2148
+ return error;
2149
+ }
2150
+ }
2151
+ return null;
2152
+ }
2153
+ return createChainableTypeChecker(validate);
2154
+ }
2155
+
2156
+ function createElementTypeChecker() {
2157
+ function validate(props, propName, componentName, location, propFullName) {
2158
+ var propValue = props[propName];
2159
+ if (!isValidElement(propValue)) {
2160
+ var propType = getPropType(propValue);
2161
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
2162
+ }
2163
+ return null;
2164
+ }
2165
+ return createChainableTypeChecker(validate);
2166
+ }
2167
+
2168
+ function createInstanceTypeChecker(expectedClass) {
2169
+ function validate(props, propName, componentName, location, propFullName) {
2170
+ if (!(props[propName] instanceof expectedClass)) {
2171
+ var expectedClassName = expectedClass.name || ANONYMOUS;
2172
+ var actualClassName = getClassName(props[propName]);
2173
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
2174
+ }
2175
+ return null;
2176
+ }
2177
+ return createChainableTypeChecker(validate);
2178
+ }
2179
+
2180
+ function createEnumTypeChecker(expectedValues) {
2181
+ if (!Array.isArray(expectedValues)) {
2182
+ process.env.NODE_ENV !== 'production' ? process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0 : void 0;
2183
+ return emptyFunction.thatReturnsNull;
2184
+ }
2185
+
2186
+ function validate(props, propName, componentName, location, propFullName) {
2187
+ var propValue = props[propName];
2188
+ for (var i = 0; i < expectedValues.length; i++) {
2189
+ if (is(propValue, expectedValues[i])) {
2190
+ return null;
2191
+ }
2192
+ }
2193
+
2194
+ var valuesString = JSON.stringify(expectedValues);
2195
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
2196
+ }
2197
+ return createChainableTypeChecker(validate);
2198
+ }
2199
+
2200
+ function createObjectOfTypeChecker(typeChecker) {
2201
+ function validate(props, propName, componentName, location, propFullName) {
2202
+ if (typeof typeChecker !== 'function') {
2203
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
2204
+ }
2205
+ var propValue = props[propName];
2206
+ var propType = getPropType(propValue);
2207
+ if (propType !== 'object') {
2208
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
2209
+ }
2210
+ for (var key in propValue) {
2211
+ if (propValue.hasOwnProperty(key)) {
2212
+ var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
2213
+ if (error instanceof Error) {
2214
+ return error;
2215
+ }
2216
+ }
2217
+ }
2218
+ return null;
2219
+ }
2220
+ return createChainableTypeChecker(validate);
2221
+ }
2222
+
2223
+ function createUnionTypeChecker(arrayOfTypeCheckers) {
2224
+ if (!Array.isArray(arrayOfTypeCheckers)) {
2225
+ process.env.NODE_ENV !== 'production' ? process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0 : void 0;
2226
+ return emptyFunction.thatReturnsNull;
2227
+ }
2228
+
2229
+ function validate(props, propName, componentName, location, propFullName) {
2230
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
2231
+ var checker = arrayOfTypeCheckers[i];
2232
+ if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
2233
+ return null;
2234
+ }
2235
+ }
2236
+
2237
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
2238
+ }
2239
+ return createChainableTypeChecker(validate);
2240
+ }
2241
+
2242
+ function createNodeChecker() {
2243
+ function validate(props, propName, componentName, location, propFullName) {
2244
+ if (!isNode(props[propName])) {
2245
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
2246
+ }
2247
+ return null;
2248
+ }
2249
+ return createChainableTypeChecker(validate);
2250
+ }
2251
+
2252
+ function createShapeTypeChecker(shapeTypes) {
2253
+ function validate(props, propName, componentName, location, propFullName) {
2254
+ var propValue = props[propName];
2255
+ var propType = getPropType(propValue);
2256
+ if (propType !== 'object') {
2257
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
2258
+ }
2259
+ for (var key in shapeTypes) {
2260
+ var checker = shapeTypes[key];
2261
+ if (!checker) {
2262
+ continue;
2263
+ }
2264
+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
2265
+ if (error) {
2266
+ return error;
2267
+ }
2268
+ }
2269
+ return null;
2270
+ }
2271
+ return createChainableTypeChecker(validate);
2272
+ }
2273
+
2274
+ function isNode(propValue) {
2275
+ switch (typeof propValue === 'undefined' ? 'undefined' : _typeof(propValue)) {
2276
+ case 'number':
2277
+ case 'string':
2278
+ case 'undefined':
2279
+ return true;
2280
+ case 'boolean':
2281
+ return !propValue;
2282
+ case 'object':
2283
+ if (Array.isArray(propValue)) {
2284
+ return propValue.every(isNode);
2285
+ }
2286
+ if (propValue === null || isValidElement(propValue)) {
2287
+ return true;
2288
+ }
2289
+
2290
+ var iteratorFn = getIteratorFn(propValue);
2291
+ if (iteratorFn) {
2292
+ var iterator = iteratorFn.call(propValue);
2293
+ var step;
2294
+ if (iteratorFn !== propValue.entries) {
2295
+ while (!(step = iterator.next()).done) {
2296
+ if (!isNode(step.value)) {
2297
+ return false;
2298
+ }
2299
+ }
2300
+ } else {
2301
+ // Iterator will provide entry [k,v] tuples rather than values.
2302
+ while (!(step = iterator.next()).done) {
2303
+ var entry = step.value;
2304
+ if (entry) {
2305
+ if (!isNode(entry[1])) {
2306
+ return false;
2307
+ }
2308
+ }
2309
+ }
2310
+ }
2311
+ } else {
2312
+ return false;
2313
+ }
2314
+
2315
+ return true;
2316
+ default:
2317
+ return false;
2318
+ }
2319
+ }
2320
+
2321
+ function isSymbol(propType, propValue) {
2322
+ // Native Symbol.
2323
+ if (propType === 'symbol') {
2324
+ return true;
2325
+ }
2326
+
2327
+ // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
2328
+ if (propValue['@@toStringTag'] === 'Symbol') {
2329
+ return true;
2330
+ }
2331
+
2332
+ // Fallback for non-spec compliant Symbols which are polyfilled.
2333
+ if (typeof Symbol === 'function' && propValue instanceof Symbol) {
2334
+ return true;
2335
+ }
2336
+
2337
+ return false;
2338
+ }
2339
+
2340
+ // Equivalent of `typeof` but with special handling for array and regexp.
2341
+ function getPropType(propValue) {
2342
+ var propType = typeof propValue === 'undefined' ? 'undefined' : _typeof(propValue);
2343
+ if (Array.isArray(propValue)) {
2344
+ return 'array';
2345
+ }
2346
+ if (propValue instanceof RegExp) {
2347
+ // Old webkits (at least until Android 4.0) return 'function' rather than
2348
+ // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
2349
+ // passes PropTypes.object.
2350
+ return 'object';
2351
+ }
2352
+ if (isSymbol(propType, propValue)) {
2353
+ return 'symbol';
2354
+ }
2355
+ return propType;
2356
+ }
2357
+
2358
+ // This handles more types than `getPropType`. Only used for error messages.
2359
+ // See `createPrimitiveTypeChecker`.
2360
+ function getPreciseType(propValue) {
2361
+ var propType = getPropType(propValue);
2362
+ if (propType === 'object') {
2363
+ if (propValue instanceof Date) {
2364
+ return 'date';
2365
+ } else if (propValue instanceof RegExp) {
2366
+ return 'regexp';
2367
+ }
2368
+ }
2369
+ return propType;
2370
+ }
2371
+
2372
+ // Returns class name of the object, if any.
2373
+ function getClassName(propValue) {
2374
+ if (!propValue.constructor || !propValue.constructor.name) {
2375
+ return ANONYMOUS;
2376
+ }
2377
+ return propValue.constructor.name;
2378
+ }
2379
+
2380
+ ReactPropTypes.checkPropTypes = checkPropTypes;
2381
+ ReactPropTypes.PropTypes = ReactPropTypes;
2382
+
2383
+ return ReactPropTypes;
2384
+ };
2385
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
2386
+
2387
+ /***/ }),
2388
+ /* 17 */
2389
+ /***/ (function(module, exports, __webpack_require__) {
2390
+
2391
+ "use strict";
2392
+
2393
+
2394
+ var _CSSTransition = __webpack_require__(9);
2395
+
2396
+ var _CSSTransition2 = _interopRequireDefault(_CSSTransition);
2397
+
2398
+ var _TransitionGroup = __webpack_require__(10);
2399
+
2400
+ var _TransitionGroup2 = _interopRequireDefault(_TransitionGroup);
2401
+
2402
+ var _Transition = __webpack_require__(5);
2403
+
2404
+ var _Transition2 = _interopRequireDefault(_Transition);
2405
+
2406
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2407
+
2408
+ module.exports = {
2409
+ Transition: _Transition2.default,
2410
+ TransitionGroup: _TransitionGroup2.default,
2411
+ CSSTransition: _CSSTransition2.default
2412
+ };
2413
+
2414
+ /***/ }),
2415
+ /* 18 */
2416
+ /***/ (function(module, exports, __webpack_require__) {
2417
+
2418
+ "use strict";
2419
+
2420
+
2421
+ exports.__esModule = true;
2422
+ exports.getChildMapping = getChildMapping;
2423
+ exports.mergeChildMappings = mergeChildMappings;
2424
+
2425
+ var _react = __webpack_require__(2);
2426
+
2427
+ /**
2428
+ * Given `this.props.children`, return an object mapping key to child.
2429
+ *
2430
+ * @param {*} children `this.props.children`
2431
+ * @return {object} Mapping of key to child
2432
+ */
2433
+ function getChildMapping(children, mapFn) {
2434
+ var mapper = function mapper(child) {
2435
+ return mapFn && (0, _react.isValidElement)(child) ? mapFn(child) : child;
2436
+ };
2437
+
2438
+ var result = Object.create(null);
2439
+ if (children) _react.Children.map(children, function (c) {
2440
+ return c;
2441
+ }).forEach(function (child) {
2442
+ // run the map function here instead so that the key is the computed one
2443
+ result[child.key] = mapper(child);
2444
+ });
2445
+ return result;
2446
+ }
2447
+
2448
+ /**
2449
+ * When you're adding or removing children some may be added or removed in the
2450
+ * same render pass. We want to show *both* since we want to simultaneously
2451
+ * animate elements in and out. This function takes a previous set of keys
2452
+ * and a new set of keys and merges them with its best guess of the correct
2453
+ * ordering. In the future we may expose some of the utilities in
2454
+ * ReactMultiChild to make this easy, but for now React itself does not
2455
+ * directly have this concept of the union of prevChildren and nextChildren
2456
+ * so we implement it here.
2457
+ *
2458
+ * @param {object} prev prev children as returned from
2459
+ * `ReactTransitionChildMapping.getChildMapping()`.
2460
+ * @param {object} next next children as returned from
2461
+ * `ReactTransitionChildMapping.getChildMapping()`.
2462
+ * @return {object} a key set that contains all keys in `prev` and all keys
2463
+ * in `next` in a reasonable order.
2464
+ */
2465
+ function mergeChildMappings(prev, next) {
2466
+ prev = prev || {};
2467
+ next = next || {};
2468
+
2469
+ function getValueForKey(key) {
2470
+ return key in next ? next[key] : prev[key];
2471
+ }
2472
+
2473
+ // For each key of `next`, the list of keys to insert before that key in
2474
+ // the combined list
2475
+ var nextKeysPending = Object.create(null);
2476
+
2477
+ var pendingKeys = [];
2478
+ for (var prevKey in prev) {
2479
+ if (prevKey in next) {
2480
+ if (pendingKeys.length) {
2481
+ nextKeysPending[prevKey] = pendingKeys;
2482
+ pendingKeys = [];
2483
+ }
2484
+ } else {
2485
+ pendingKeys.push(prevKey);
2486
+ }
2487
+ }
2488
+
2489
+ var i = void 0;
2490
+ var childMapping = {};
2491
+ for (var nextKey in next) {
2492
+ if (nextKeysPending[nextKey]) {
2493
+ for (i = 0; i < nextKeysPending[nextKey].length; i++) {
2494
+ var pendingNextKey = nextKeysPending[nextKey][i];
2495
+ childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);
2496
+ }
2497
+ }
2498
+ childMapping[nextKey] = getValueForKey(nextKey);
2499
+ }
2500
+
2501
+ // Finally, add the keys which didn't appear before any key in `next`
2502
+ for (i = 0; i < pendingKeys.length; i++) {
2503
+ childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);
2504
+ }
2505
+
2506
+ return childMapping;
2507
+ }
2508
+
2509
+ /***/ }),
2510
+ /* 19 */
2511
+ /***/ (function(module, exports) {
2512
+
2513
+ module.exports = __WEBPACK_EXTERNAL_MODULE_19__;
2514
+
2515
+ /***/ })
2516
+ /******/ ]);
2517
+ });
assets/js/views/attribute-select.jsx ADDED
@@ -0,0 +1,345 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { __ } = wp.i18n;
2
+ const { Toolbar, withAPIData, Dropdown, Dashicon } = wp.components;
3
+
4
+ /**
5
+ * Attribute data cache.
6
+ * Needed because it takes a lot of API calls to generate attribute info.
7
+ */
8
+ const PRODUCT_ATTRIBUTE_DATA = {};
9
+
10
+ /**
11
+ * Get the identifier for an attribute. The identifier can be used to determine
12
+ * the slug or the ID of the attribute.
13
+ *
14
+ * @param string slug The attribute slug.
15
+ * @param int|numeric string id The attribute ID.
16
+ */
17
+ export function getAttributeIdentifier( slug, id ) {
18
+ return slug + ',' + id;
19
+ }
20
+
21
+ /**
22
+ * Get the attribute slug from an identifier.
23
+ *
24
+ * @param string identifier The attribute identifier.
25
+ * @return string
26
+ */
27
+ export function getAttributeSlug( identifier ) {
28
+ return identifier.split( ',' )[0];
29
+ }
30
+
31
+ /**
32
+ * Get the attribute ID from an identifier.
33
+ *
34
+ * @param string identifier The attribute identifier.
35
+ * @return numeric string
36
+ */
37
+ export function getAttributeID( identifier ) {
38
+ return identifier.split( ',' )[1];
39
+ }
40
+
41
+ /**
42
+ * When the display mode is 'Attribute' search for and select product attributes to pull products from.
43
+ */
44
+ export class ProductsAttributeSelect extends React.Component {
45
+
46
+ /**
47
+ * Constructor.
48
+ */
49
+ constructor( props ) {
50
+ super( props );
51
+
52
+ /**
53
+ * The first item in props.selected_display_setting is the attribute slug and id separated by a comma.
54
+ * This is to work around limitations in the API which sometimes requires a slug and sometimes an id.
55
+ * The rest of the elements in selected_display_setting are the term ids for any selected terms.
56
+ */
57
+ this.state = {
58
+ selectedAttribute: props.selected_display_setting.length ? props.selected_display_setting[0] : '',
59
+ selectedTerms: props.selected_display_setting.length > 1 ? props.selected_display_setting.slice( 1 ) : [],
60
+ filterQuery: '',
61
+ }
62
+
63
+ this.setSelectedAttribute = this.setSelectedAttribute.bind( this );
64
+ this.addTerm = this.addTerm.bind( this );
65
+ this.removeTerm = this.removeTerm.bind( this );
66
+ }
67
+
68
+ /**
69
+ * Set the selected attribute.
70
+ *
71
+ * @param identifier string Attribute slug and id separated by a comma.
72
+ */
73
+ setSelectedAttribute( identifier ) {
74
+ this.setState( {
75
+ selectedAttribute: identifier,
76
+ selectedTerms: [],
77
+ } );
78
+
79
+ this.props.update_display_setting_callback( [ identifier ] );
80
+ }
81
+
82
+ /**
83
+ * Add a term to the selected attribute's terms.
84
+ *
85
+ * @param id int Term id.
86
+ */
87
+ addTerm( id ) {
88
+ let terms = this.state.selectedTerms;
89
+ terms.push( id );
90
+ this.setState( {
91
+ selectedTerms: terms,
92
+ } );
93
+
94
+ let displaySetting = [ this.state.selectedAttribute ];
95
+ displaySetting = displaySetting.concat( terms );
96
+ this.props.update_display_setting_callback( displaySetting );
97
+ }
98
+
99
+ /**
100
+ * Remove a term from the selected attribute's terms.
101
+ *
102
+ * @param id int Term id.
103
+ */
104
+ removeTerm( id ) {
105
+ let newTerms = [];
106
+ for ( let termId of this.state.selectedTerms ) {
107
+ if ( termId !== id ) {
108
+ newTerms.push( termId );
109
+ }
110
+ }
111
+
112
+ this.setState( {
113
+ selectedTerms: newTerms,
114
+ } );
115
+
116
+ let displaySetting = [ this.state.selectedAttribute ];
117
+ displaySetting = displaySetting.concat( newTerms );
118
+ this.props.update_display_setting_callback( displaySetting );
119
+ }
120
+
121
+ /**
122
+ * Update the search results when typing in the attributes box.
123
+ *
124
+ * @param evt Event object
125
+ */
126
+ updateFilter( evt ) {
127
+ this.setState( {
128
+ filterQuery: evt.target.value,
129
+ } );
130
+ }
131
+
132
+ /**
133
+ * Render the whole section.
134
+ */
135
+ render() {
136
+ return (
137
+ <div className="wc-products-list-card wc-products-list-card--taxonomy wc-products-list-card--taxonomy-atributes">
138
+ <ProductAttributeFilter updateFilter={ this.updateFilter.bind( this ) } />
139
+ <ProductAttributeList
140
+ selectedAttribute={ this.state.selectedAttribute }
141
+ selectedTerms={ this.state.selectedTerms }
142
+ filterQuery={ this.state.filterQuery }
143
+ setSelectedAttribute={ this.setSelectedAttribute.bind( this ) }
144
+ addTerm={ this.addTerm.bind( this ) }
145
+ removeTerm={ this.removeTerm.bind( this ) }
146
+ />
147
+ </div>
148
+ );
149
+ }
150
+ }
151
+
152
+ /**
153
+ * Search area for filtering through the attributes list.
154
+ */
155
+ const ProductAttributeFilter = ( props ) => {
156
+ return (
157
+ <div className="wc-products-list-card__input-wrapper">
158
+ <Dashicon icon="search" />
159
+ <input className="wc-products-list-card__search" type="search" placeholder={ __( 'Search for attributes' ) } onChange={ props.updateFilter } />
160
+ </div>
161
+ );
162
+ }
163
+
164
+ /**
165
+ * List of attributes.
166
+ */
167
+ const ProductAttributeList = withAPIData( ( props ) => {
168
+ return {
169
+ attributes: '/wc/v2/products/attributes'
170
+ };
171
+ } )( ( { attributes, selectedAttribute, filterQuery, selectedTerms, setSelectedAttribute, addTerm, removeTerm } ) => {
172
+ if ( ! attributes.data ) {
173
+ return __( 'Loading' );
174
+ }
175
+
176
+ if ( 0 === attributes.data.length ) {
177
+ return __( 'No attributes found' );
178
+ }
179
+
180
+
181
+ const filter = filterQuery.toLowerCase();
182
+ let attributeElements = [];
183
+ for ( let attribute of attributes.data ) {
184
+
185
+ // Filter out attributes that don't match the search query.
186
+ if ( filter.length && -1 === attribute.name.toLowerCase().indexOf( filter ) ) {
187
+ continue;
188
+ }
189
+
190
+ if ( PRODUCT_ATTRIBUTE_DATA.hasOwnProperty( attribute.slug ) ) {
191
+ attributeElements.push( <ProductAttributeElement
192
+ selectedAttribute={ selectedAttribute }
193
+ selectedTerms={ selectedTerms }
194
+ attribute={attribute}
195
+ setSelectedAttribute={ setSelectedAttribute }
196
+ addTerm={ addTerm }
197
+ removeTerm={ removeTerm }
198
+ /> );
199
+ } else {
200
+ attributeElements.push( <UncachedProductAttributeElement
201
+ selectedAttribute={ selectedAttribute }
202
+ selectedTerms={ selectedTerms }
203
+ attribute={ attribute }
204
+ setSelectedAttribute={ setSelectedAttribute }
205
+ addTerm={ addTerm }
206
+ removeTerm={ removeTerm }
207
+ /> );
208
+ }
209
+ }
210
+
211
+ return (
212
+ <div className="wc-products-list-card__results">
213
+ { attributeElements }
214
+ </div>
215
+ );
216
+ }
217
+ );
218
+
219
+ /**
220
+ * Caches then renders a product attribute term element.
221
+ */
222
+ const UncachedProductAttributeElement = withAPIData( ( props ) => {
223
+ return {
224
+ terms: '/wc/v2/products/attributes/' + props.attribute.id + '/terms'
225
+ };
226
+ } )( ( { terms, selectedAttribute, selectedTerms, attribute, setSelectedAttribute, addTerm, removeTerm } ) => {
227
+ if ( ! terms.data || 0 === terms.data.length ) {
228
+ return null;
229
+ }
230
+
231
+ // Populate cache.
232
+ PRODUCT_ATTRIBUTE_DATA[ attribute.slug ] = { terms: [] };
233
+
234
+ let totalCount = 0;
235
+ for ( let term of terms.data ) {
236
+ totalCount += term.count;
237
+ PRODUCT_ATTRIBUTE_DATA[ attribute.slug ].terms.push( term );
238
+ }
239
+
240
+ PRODUCT_ATTRIBUTE_DATA[ attribute.slug ].count = totalCount;
241
+
242
+ return <ProductAttributeElement
243
+ selectedAttribute={ selectedAttribute }
244
+ selectedTerms={ selectedTerms }
245
+ attribute={ attribute }
246
+ setSelectedAttribute={ setSelectedAttribute }
247
+ addTerm={ addTerm }
248
+ removeTerm={ removeTerm }
249
+ />
250
+ }
251
+ );
252
+
253
+ /**
254
+ * A product attribute term element.
255
+ */
256
+ class ProductAttributeElement extends React.Component {
257
+
258
+ /**
259
+ * Constructor.
260
+ */
261
+ constructor( props ) {
262
+ super( props );
263
+
264
+ this.handleAttributeChange = this.handleAttributeChange.bind( this );
265
+ this.handleTermChange = this.handleTermChange.bind( this );
266
+ }
267
+
268
+ /**
269
+ * Propagate and reset values when the selected attribute is changed.
270
+ *
271
+ * @param evt Event object
272
+ */
273
+ handleAttributeChange( evt ) {
274
+ if ( ! evt.target.checked ) {
275
+ return;
276
+ }
277
+
278
+ this.props.setSelectedAttribute( evt.target.value );
279
+ }
280
+
281
+ /**
282
+ * Add or remove selected terms.
283
+ *
284
+ * @param evt Event object
285
+ */
286
+ handleTermChange( evt ) {
287
+ if ( evt.target.checked ) {
288
+ this.props.addTerm( evt.target.value );
289
+ } else {
290
+ this.props.removeTerm( evt.target.value );
291
+ }
292
+ }
293
+
294
+ /**
295
+ * Render the details for one attribute.
296
+ */
297
+ render() {
298
+ const attribute = PRODUCT_ATTRIBUTE_DATA[ this.props.attribute.slug ];
299
+ const isSelected = this.props.selectedAttribute === getAttributeIdentifier( this.props.attribute.slug, this.props.attribute.id );
300
+
301
+ let attributeTerms = null;
302
+ if ( isSelected ) {
303
+ attributeTerms = (
304
+ <ul>
305
+ { attribute.terms.map( ( term ) => (
306
+ <li className="wc-products-list-card__item">
307
+ <label className="wc-products-list-card__content">
308
+ <input type="checkbox"
309
+ value={ term.id }
310
+ onChange={ this.handleTermChange }
311
+ checked={ this.props.selectedTerms.includes( String( term.id ) ) }
312
+ />
313
+ { term.name }
314
+ <span className="wc-products-list-card__taxonomy-count">{ term.count }</span>
315
+ </label>
316
+ </li>
317
+ ) ) }
318
+ </ul>
319
+ );
320
+ }
321
+
322
+ let cssClasses = [ 'wc-products-list-card--taxonomy-atributes__atribute' ];
323
+
324
+ if ( isSelected ) {
325
+ cssClasses.push( 'wc-products-list-card__accordion-open' );
326
+ }
327
+
328
+ return (
329
+ <div className={ cssClasses.join( ' ' ) }>
330
+ <div>
331
+ <label className="wc-products-list-card__content">
332
+ <input type="radio"
333
+ value={ getAttributeIdentifier( this.props.attribute.slug, this.props.attribute.id ) }
334
+ onChange={ this.handleAttributeChange }
335
+ checked={ isSelected }
336
+ />
337
+ { this.props.attribute.name }
338
+ <span className="wc-products-list-card__taxonomy-count">{ attribute.count }</span>
339
+ </label>
340
+ </div>
341
+ { attributeTerms }
342
+ </div>
343
+ );
344
+ }
345
+ }
assets/js/views/category-select.jsx ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { __ } = wp.i18n;
2
+ const { Toolbar, withAPIData, Dropdown, Dashicon } = wp.components;
3
+
4
+ /**
5
+ * When the display mode is 'Product category' search for and select product categories to pull products from.
6
+ */
7
+ export class ProductsCategorySelect extends React.Component {
8
+
9
+ /**
10
+ * Constructor.
11
+ */
12
+ constructor( props ) {
13
+ super( props );
14
+
15
+ this.state = {
16
+ selectedCategories: props.selected_display_setting,
17
+ openAccordion: [],
18
+ filterQuery: '',
19
+ firstLoad: true,
20
+ }
21
+
22
+ this.checkboxChange = this.checkboxChange.bind( this );
23
+ this.accordionToggle = this.accordionToggle.bind( this );
24
+ this.filterResults = this.filterResults.bind( this );
25
+ this.setFirstLoad = this.setFirstLoad.bind( this );
26
+ }
27
+
28
+ /**
29
+ * Handle checkbox toggle.
30
+ *
31
+ * @param Checked? boolean checked
32
+ * @param Categories array categories
33
+ */
34
+ checkboxChange( checked, categories ) {
35
+ let selectedCategories = this.state.selectedCategories;
36
+
37
+ selectedCategories = selectedCategories.filter( category => ! categories.includes( category ) );
38
+
39
+ if ( checked ) {
40
+ selectedCategories.push( ...categories );
41
+ }
42
+
43
+ this.setState( {
44
+ selectedCategories: selectedCategories
45
+ } );
46
+
47
+ this.props.update_display_setting_callback( selectedCategories );
48
+ }
49
+
50
+ /**
51
+ * Handle accordion toggle.
52
+ *
53
+ * @param Category ID category
54
+ */
55
+ accordionToggle( category ) {
56
+ let openAccordions = this.state.openAccordion;
57
+
58
+ if ( openAccordions.includes( category ) ) {
59
+ openAccordions = openAccordions.filter( c => c !== category );
60
+ } else {
61
+ openAccordions.push( category );
62
+ }
63
+
64
+ this.setState( {
65
+ openAccordion: openAccordions
66
+ } );
67
+ }
68
+
69
+ /**
70
+ * Filter categories.
71
+ *
72
+ * @param Event object evt
73
+ */
74
+ filterResults( evt ) {
75
+ this.setState( {
76
+ filterQuery: evt.target.value
77
+ } );
78
+ }
79
+
80
+ /**
81
+ * Update firstLoad state.
82
+ *
83
+ * @param Booolean loaded
84
+ */
85
+ setFirstLoad( loaded ) {
86
+ this.setState( {
87
+ firstLoad: !! loaded
88
+ } );
89
+ }
90
+
91
+ /**
92
+ * Render the list of categories and the search input.
93
+ */
94
+ render() {
95
+ return (
96
+ <div className="wc-products-list-card wc-products-list-card--taxonomy wc-products-list-card--taxonomy-category">
97
+ <ProductCategoryFilter filterResults={ this.filterResults } />
98
+ <ProductCategoryList
99
+ filterQuery={ this.state.filterQuery }
100
+ selectedCategories={ this.state.selectedCategories }
101
+ checkboxChange={ this.checkboxChange }
102
+ accordionToggle={ this.accordionToggle }
103
+ openAccordion={ this.state.openAccordion }
104
+ firstLoad={ this.state.firstLoad }
105
+ setFirstLoad={ this.setFirstLoad }
106
+ />
107
+ </div>
108
+ );
109
+ }
110
+ }
111
+
112
+ /**
113
+ * The category search input.
114
+ */
115
+ const ProductCategoryFilter = ( { filterResults } ) => {
116
+ return (
117
+ <div className="wc-products-list-card__input-wrapper">
118
+ <Dashicon icon="search" />
119
+ <input className="wc-products-list-card__search" type="search" placeholder={ __( 'Search for categories' ) } onChange={ filterResults } />
120
+ </div>
121
+ );
122
+ }
123
+
124
+ /**
125
+ * Fetch and build a tree of product categories.
126
+ */
127
+ const ProductCategoryList = withAPIData( ( props ) => {
128
+ return {
129
+ categories: '/wc/v2/products/categories'
130
+ };
131
+ } )( ( { categories, filterQuery, selectedCategories, checkboxChange, accordionToggle, openAccordion, firstLoad, setFirstLoad } ) => {
132
+ if ( ! categories.data ) {
133
+ return __( 'Loading' );
134
+ }
135
+
136
+ if ( 0 === categories.data.length ) {
137
+ return __( 'No categories found' );
138
+ }
139
+
140
+ const handleCategoriesToCheck = ( evt, parent, categories ) => {
141
+ let ids = getCategoryChildren( parent, categories ).map( category => {
142
+ return category.id;
143
+ } );
144
+
145
+ ids.push( parent.id );
146
+
147
+ checkboxChange( evt.target.checked, ids );
148
+ };
149
+
150
+ const getCategoryChildren = ( parent, categories ) => {
151
+ let children = [];
152
+
153
+ categories.filter( ( category ) => category.parent === parent.id ).forEach( function( category ) {
154
+ children.push( category );
155
+ children.push( ...getCategoryChildren( category, categories ) );
156
+ } );
157
+
158
+ return children;
159
+ };
160
+
161
+ const categoryHasChildren = ( parent, categories ) => {
162
+ return !! getCategoryChildren( parent, categories ).length;
163
+ };
164
+
165
+ const isIndeterminate = ( category, categories ) => {
166
+
167
+ // Currect category selected?
168
+ if ( selectedCategories.includes( category.id ) ) {
169
+ return false;
170
+ }
171
+
172
+ // Has children?
173
+ let children = getCategoryChildren( category, categories ).map( category => {
174
+ return category.id;
175
+ } );
176
+
177
+ for ( let child of children ) {
178
+ if ( selectedCategories.includes( child ) ) {
179
+ return true;
180
+ }
181
+ }
182
+
183
+ return false;
184
+ }
185
+
186
+ const AccordionButton = ( { category, categories } ) => {
187
+ let icon = 'arrow-down-alt2';
188
+
189
+ if ( openAccordion.includes( category.id ) ) {
190
+ icon = 'arrow-up-alt2';
191
+ }
192
+
193
+ let style = null;
194
+
195
+ if ( ! categoryHasChildren( category, categories ) ) {
196
+ style = {
197
+ visibility: 'hidden',
198
+ };
199
+ };
200
+
201
+ return (
202
+ <button onClick={ () => accordionToggle( category.id ) } className="wc-products-list-card__accordion-button" style={ style } type="button">
203
+ <Dashicon icon={ icon } />
204
+ </button>
205
+ );
206
+ };
207
+
208
+ const CategoryTree = ( { categories, parent } ) => {
209
+ let filteredCategories = categories.filter( ( category ) => category.parent === parent );
210
+
211
+ if ( firstLoad && selectedCategories.length > 0 ) {
212
+ categoriesData.filter( ( category ) => category.parent === 0 ).forEach( function( category ) {
213
+ let children = getCategoryChildren( category, categoriesData );
214
+
215
+ for ( let child of children ) {
216
+ if ( selectedCategories.includes( child.id ) && ! openAccordion.includes( category.id ) ) {
217
+ accordionToggle( category.id );
218
+ break;
219
+ }
220
+ }
221
+ } );
222
+
223
+ setFirstLoad( false );
224
+ }
225
+
226
+ return ( filteredCategories.length > 0 ) && (
227
+ <ul>
228
+ { filteredCategories.map( ( category ) => (
229
+ <li key={ category.id } className={ ( openAccordion.includes( category.id ) ? 'wc-products-list-card__item wc-products-list-card__accordion-open' : 'wc-products-list-card__item' ) }>
230
+ <label className={ ( 0 === category.parent ) ? 'wc-products-list-card__content' : '' } htmlFor={ 'product-category-' + category.id }>
231
+ <input type="checkbox"
232
+ id={ 'product-category-' + category.id }
233
+ value={ category.id }
234
+ checked={ selectedCategories.includes( category.id ) }
235
+ onChange={ ( evt ) => handleCategoriesToCheck( evt, category, categories ) }
236
+ ref={ el => el && ( el.indeterminate = isIndeterminate( category, categories ) ) }
237
+ /> { category.name }
238
+ { 0 === category.parent &&
239
+ <AccordionButton category={ category } categories={ categories } />
240
+ }
241
+ <span className="wc-products-list-card__taxonomy-count">{ category.count }</span>
242
+ </label>
243
+ <CategoryTree categories={ categories } parent={ category.id } />
244
+ </li>
245
+ ) ) }
246
+ </ul>
247
+ );
248
+ };
249
+
250
+ let categoriesData = categories.data;
251
+
252
+ if ( '' !== filterQuery ) {
253
+ categoriesData = categoriesData.filter( category => category.slug.includes( filterQuery.toLowerCase() ) );
254
+ }
255
+
256
+ return (
257
+ <div className="wc-products-list-card__results">
258
+ <CategoryTree categories={ categoriesData } parent={ 0 } />
259
+ </div>
260
+ );
261
+ }
262
+ );
assets/js/views/specific-select.jsx ADDED
@@ -0,0 +1,368 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { __ } = wp.i18n;
2
+ const { Toolbar, withAPIData, Dropdown, Dashicon } = wp.components;
3
+
4
+ /**
5
+ * Product data cache.
6
+ * Reduces the number of API calls and makes UI smoother and faster.
7
+ */
8
+ const PRODUCT_DATA = {};
9
+
10
+ /**
11
+ * When the display mode is 'Specific products' search for and add products to the block.
12
+ *
13
+ * @todo Add the functionality and everything.
14
+ */
15
+ export class ProductsSpecificSelect extends React.Component {
16
+
17
+ /**
18
+ * Constructor.
19
+ */
20
+ constructor( props ) {
21
+ super( props );
22
+
23
+ this.state = {
24
+ selectedProducts: props.selected_display_setting || [],
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Add a product to the list of selected products.
30
+ *
31
+ * @param id int Product ID.
32
+ */
33
+ addOrRemoveProduct( id ) {
34
+ let selectedProducts = this.state.selectedProducts;
35
+
36
+ if ( ! selectedProducts.includes( id ) ) {
37
+ selectedProducts.push( id );
38
+ } else {
39
+ selectedProducts = selectedProducts.filter( product => product !== id );
40
+ }
41
+
42
+ this.setState( {
43
+ selectedProducts: selectedProducts
44
+ } );
45
+
46
+ /**
47
+ * We need to copy the existing data into a new array.
48
+ * We can't just push the new product onto the end of the existing array because Gutenberg seems
49
+ * to do some sort of check by reference to determine whether to *actually* update the attribute
50
+ * and will not update it if we just pass back the same array with an extra element on the end.
51
+ */
52
+ this.props.update_display_setting_callback( selectedProducts.slice() );
53
+ }
54
+
55
+ /**
56
+ * Render the product specific select screen.
57
+ */
58
+ render() {
59
+ return (
60
+ <div className="wc-products-list-card wc-products-list-card--specific">
61
+ <ProductsSpecificSearchField
62
+ addOrRemoveProductCallback={ this.addOrRemoveProduct.bind( this ) }
63
+ selectedProducts={ this.state.selectedProducts }
64
+ />
65
+ <ProductSpecificSelectedProducts
66
+ columns={ this.props.attributes.columns }
67
+ productIds={ this.state.selectedProducts }
68
+ addOrRemoveProduct={ this.addOrRemoveProduct.bind( this ) }
69
+ />
70
+ </div>
71
+ );
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Product search area
77
+ */
78
+ class ProductsSpecificSearchField extends React.Component {
79
+
80
+ /**
81
+ * Constructor.
82
+ */
83
+ constructor( props ) {
84
+ super( props );
85
+
86
+ this.state = {
87
+ searchText: '',
88
+ dropdownOpen: false,
89
+ }
90
+
91
+ this.updateSearchResults = this.updateSearchResults.bind( this );
92
+ this.setWrapperRef = this.setWrapperRef.bind( this );
93
+ this.handleClickOutside = this.handleClickOutside.bind( this );
94
+ this.isDropdownOpen = this.isDropdownOpen.bind( this );
95
+ }
96
+
97
+ /**
98
+ * Hook in the listener for closing menu when clicked outside.
99
+ */
100
+ componentDidMount() {
101
+ document.addEventListener( 'mousedown', this.handleClickOutside );
102
+ }
103
+
104
+ /**
105
+ * Remove the listener for closing menu when clicked outside.
106
+ */
107
+ componentWillUnmount() {
108
+ document.removeEventListener( 'mousedown', this.handleClickOutside );
109
+ }
110
+
111
+ /**
112
+ * Set the wrapper reference.
113
+ *
114
+ * @param node DOMNode
115
+ */
116
+ setWrapperRef( node ) {
117
+ this.wrapperRef = node;
118
+ }
119
+
120
+ /**
121
+ * Close the menu when user clicks outside the search area.
122
+ */
123
+ handleClickOutside( evt ) {
124
+ if ( this.wrapperRef && ! this.wrapperRef.contains( event.target ) ) {
125
+ this.setState( {
126
+ searchText: '',
127
+ } );
128
+ }
129
+ }
130
+
131
+ isDropdownOpen( isOpen ) {
132
+ this.setState( {
133
+ dropdownOpen: !! isOpen,
134
+ } );
135
+ }
136
+
137
+ /**
138
+ * Event handler for updating results when text is typed into the input.
139
+ *
140
+ * @param evt Event object.
141
+ */
142
+ updateSearchResults( evt ) {
143
+ this.setState( {
144
+ searchText: evt.target.value,
145
+ } );
146
+ }
147
+
148
+ /**
149
+ * Render the product search UI.
150
+ */
151
+ render() {
152
+ const divClass = 'wc-products-list-card__search-wrapper';
153
+
154
+ return (
155
+ <div className={ divClass + ( this.state.dropdownOpen ? ' ' + divClass + '--with-results' : '' ) } ref={ this.setWrapperRef }>
156
+ <div className="wc-products-list-card__input-wrapper">
157
+ <Dashicon icon="search" />
158
+ <input type="search"
159
+ className="wc-products-list-card__search"
160
+ value={ this.state.searchText }
161
+ placeholder={ __( 'Search for products to display' ) }
162
+ onChange={ this.updateSearchResults }
163
+ />
164
+ </div>
165
+ <ProductSpecificSearchResults
166
+ searchString={ this.state.searchText }
167
+ addOrRemoveProductCallback={ this.props.addOrRemoveProductCallback }
168
+ selectedProducts={ this.props.selectedProducts }
169
+ isDropdownOpenCallback={ this.isDropdownOpen }
170
+ />
171
+ </div>
172
+ );
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Render product search results based on the text entered into the textbox.
178
+ */
179
+ const ProductSpecificSearchResults = withAPIData( ( props ) => {
180
+
181
+ if ( ! props.searchString.length ) {
182
+ return {
183
+ products: []
184
+ };
185
+ }
186
+
187
+ return {
188
+ products: '/wc/v2/products?per_page=10&search=' + props.searchString,
189
+ };
190
+ } )( ( { products, addOrRemoveProductCallback, selectedProducts, isDropdownOpenCallback } ) => {
191
+ if ( ! products.data ) {
192
+ return null;
193
+ }
194
+
195
+ if ( 0 === products.data.length ) {
196
+ return <span className="wc-products-list-card__search-no-results"> { __( 'No products found' ) } </span>;
197
+ }
198
+
199
+ // Populate the cache.
200
+ for ( let product of products.data ) {
201
+ PRODUCT_DATA[ product.id ] = product;
202
+ }
203
+
204
+ return <ProductSpecificSearchResultsDropdown
205
+ products={ products.data }
206
+ addOrRemoveProductCallback={ addOrRemoveProductCallback }
207
+ selectedProducts={ selectedProducts }
208
+ isDropdownOpenCallback={ isDropdownOpenCallback }
209
+ />
210
+ }
211
+ );
212
+
213
+ /**
214
+ * The dropdown of search results.
215
+ */
216
+ class ProductSpecificSearchResultsDropdown extends React.Component {
217
+
218
+ /**
219
+ * Set the state of the dropdown to open.
220
+ */
221
+ componentDidMount() {
222
+ this.props.isDropdownOpenCallback( true );
223
+ }
224
+
225
+ /**
226
+ * Set the state of the dropdown to closed.
227
+ */
228
+ componentWillUnmount() {
229
+ this.props.isDropdownOpenCallback( false );
230
+ }
231
+
232
+ /**
233
+ * Render dropdown.
234
+ */
235
+ render() {
236
+ const { products, addOrRemoveProductCallback, selectedProducts } = this.props;
237
+
238
+ let productElements = [];
239
+
240
+ for ( let product of products ) {
241
+ productElements.push(
242
+ <ProductSpecificSearchResultsDropdownElement
243
+ product={product}
244
+ addOrRemoveProductCallback={ addOrRemoveProductCallback }
245
+ selected={ selectedProducts.includes( product.id ) }
246
+ />
247
+ );
248
+ }
249
+
250
+ return (
251
+ <div role="menu" className="wc-products-list-card__search-results" aria-orientation="vertical" aria-label={ __( 'Products list' ) }>
252
+ <div>
253
+ { productElements }
254
+ </div>
255
+ </div>
256
+ );
257
+ }
258
+ }
259
+
260
+ /**
261
+ * One search result.
262
+ */
263
+ class ProductSpecificSearchResultsDropdownElement extends React.Component {
264
+
265
+ /**
266
+ * Constructor.
267
+ */
268
+ constructor( props ) {
269
+ super( props );
270
+
271
+ this.handleClick = this.handleClick.bind( this );
272
+ }
273
+
274
+ /**
275
+ * Add product to main list and change UI to show it was added.
276
+ */
277
+ handleClick() {
278
+ this.props.addOrRemoveProductCallback( this.props.product.id );
279
+ }
280
+
281
+ /**
282
+ * Render one result in the search results.
283
+ */
284
+ render() {
285
+ const product = this.props.product;
286
+ let icon = this.props.selected ? <Dashicon icon="yes" /> : null;
287
+
288
+ return (
289
+ <div className={ 'wc-products-list-card__content' + ( this.props.selected ? ' wc-products-list-card__content--added' : '' ) } onClick={ this.handleClick }>
290
+ <img src={ product.images[0].src } />
291
+ <span className="wc-products-list-card__content-item-name">{ product.name }</span>
292
+ { icon }
293
+ </div>
294
+ );
295
+ }
296
+ }
297
+
298
+ /**
299
+ * List preview of selected products.
300
+ */
301
+ const ProductSpecificSelectedProducts = withAPIData( ( props ) => {
302
+ if ( ! props.productIds.length ) {
303
+ return {
304
+ products: []
305
+ };
306
+ }
307
+
308
+ // Determine which products are not already in the cache and only fetch uncached products.
309
+ let uncachedProducts = [];
310
+ for( const productId of props.productIds ) {
311
+ if ( ! PRODUCT_DATA.hasOwnProperty( productId ) ) {
312
+ uncachedProducts.push( productId );
313
+ }
314
+ }
315
+
316
+ return {
317
+ products: uncachedProducts.length ? '/wc/v2/products?include=' + uncachedProducts.join( ',' ) : []
318
+ };
319
+ } )( ( { productIds, products, columns, addOrRemoveProduct } ) => {
320
+
321
+ // Add new products to cache.
322
+ if ( products.data ) {
323
+ for ( const product of products.data ) {
324
+ PRODUCT_DATA[ product.id ] = product;
325
+ }
326
+ }
327
+
328
+ const productElements = [];
329
+
330
+ for ( const productId of productIds ) {
331
+
332
+ // Skip products that aren't in the cache yet or failed to fetch.
333
+ if ( ! PRODUCT_DATA.hasOwnProperty( productId ) ) {
334
+ continue;
335
+ }
336
+
337
+ const productData = PRODUCT_DATA[ productId ];
338
+
339
+ productElements.push(
340
+ <li className="wc-products-list-card__item">
341
+ <div className="wc-products-list-card__content">
342
+ <img src={ productData.images[0].src } />
343
+ <span className="wc-products-list-card__content-item-name">{ productData.name }</span>
344
+ <button
345
+ type="button"
346
+ id={ 'product-' + productData.id }
347
+ onClick={ function() { addOrRemoveProduct( productData.id ) } } >
348
+ <Dashicon icon="no-alt" />
349
+ </button>
350
+ </div>
351
+ </li>
352
+ );
353
+ }
354
+
355
+ return (
356
+ <div className={ 'wc-products-list-card__results-wrapper wc-products-list-card__results-wrapper--cols-' + columns }>
357
+ <div role="menu" className="wc-products-list-card__results" aria-orientation="vertical" aria-label={ __( 'Selected products' ) }>
358
+
359
+ { productElements.length > 0 && <h3>{ __( 'Selected products' ) }</h3> }
360
+
361
+ <ul>
362
+ { productElements }
363
+ </ul>
364
+ </div>
365
+ </div>
366
+ );
367
+ }
368
+ );
license.txt ADDED
@@ -0,0 +1,708 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2018 by the contributors
2
+
3
+ This program is free software; you can redistribute it and/or modify
4
+ it under the terms of the GNU General Public License as published by
5
+ the Free Software Foundation; either version 3 of the License, or
6
+ (at your option) any later version.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ GNU General Public License for more details.
12
+
13
+ You should have received a copy of the GNU General Public License
14
+ along with this program; if not, write to the Free Software
15
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ This program incorporates work covered by the following copyright and
18
+ permission notices:
19
+
20
+ Jigoshop is Copyright (c) 2011 Jigowatt Ltd.
21
+ http://jigowatt.com - http://jigoshop.com
22
+
23
+ Jigoshop is released under the GPL
24
+
25
+ and
26
+
27
+ WooCommerce - eCommerce for WordPress
28
+
29
+ WooCommerce is Copyright (c) 2018 WooThemes
30
+
31
+ WooCommerce is released under the GPL
32
+
33
+ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
34
+
35
+ GNU GENERAL PUBLIC LICENSE
36
+ Version 3, 29 June 2007
37
+
38
+ Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
39
+ Everyone is permitted to copy and distribute verbatim copies
40
+ of this license document, but changing it is not allowed.
41
+
42
+ Preamble
43
+
44
+ The GNU General Public License is a free, copyleft license for
45
+ software and other kinds of works.
46
+
47
+ The licenses for most software and other practical works are designed
48
+ to take away your freedom to share and change the works. By contrast,
49
+ the GNU General Public License is intended to guarantee your freedom to
50
+ share and change all versions of a program--to make sure it remains free
51
+ software for all its users. We, the Free Software Foundation, use the
52
+ GNU General Public License for most of our software; it applies also to
53
+ any other work released this way by its authors. You can apply it to
54
+ your programs, too.
55
+
56
+ When we speak of free software, we are referring to freedom, not
57
+ price. Our General Public Licenses are designed to make sure that you
58
+ have the freedom to distribute copies of free software (and charge for
59
+ them if you wish), that you receive source code or can get it if you
60
+ want it, that you can change the software or use pieces of it in new
61
+ free programs, and that you know you can do these things.
62
+
63
+ To protect your rights, we need to prevent others from denying you
64
+ these rights or asking you to surrender the rights. Therefore, you have
65
+ certain responsibilities if you distribute copies of the software, or if
66
+ you modify it: responsibilities to respect the freedom of others.
67
+
68
+ For example, if you distribute copies of such a program, whether
69
+ gratis or for a fee, you must pass on to the recipients the same
70
+ freedoms that you received. You must make sure that they, too, receive
71
+ or can get the source code. And you must show them these terms so they
72
+ know their rights.
73
+
74
+ Developers that use the GNU GPL protect your rights with two steps:
75
+ (1) assert copyright on the software, and (2) offer you this License
76
+ giving you legal permission to copy, distribute and/or modify it.
77
+
78
+ For the developers' and authors' protection, the GPL clearly explains
79
+ that there is no warranty for this free software. For both users' and
80
+ authors' sake, the GPL requires that modified versions be marked as
81
+ changed, so that their problems will not be attributed erroneously to
82
+ authors of previous versions.
83
+
84
+ Some devices are designed to deny users access to install or run
85
+ modified versions of the software inside them, although the manufacturer
86
+ can do so. This is fundamentally incompatible with the aim of
87
+ protecting users' freedom to change the software. The systematic
88
+ pattern of such abuse occurs in the area of products for individuals to
89
+ use, which is precisely where it is most unacceptable. Therefore, we
90
+ have designed this version of the GPL to prohibit the practice for those
91
+ products. If such problems arise substantially in other domains, we
92
+ stand ready to extend this provision to those domains in future versions
93
+ of the GPL, as needed to protect the freedom of users.
94
+
95
+ Finally, every program is threatened constantly by software patents.
96
+ States should not allow patents to restrict development and use of
97
+ software on general-purpose computers, but in those that do, we wish to
98
+ avoid the special danger that patents applied to a free program could
99
+ make it effectively proprietary. To prevent this, the GPL assures that
100
+ patents cannot be used to render the program non-free.
101
+
102
+ The precise terms and conditions for copying, distribution and
103
+ modification follow.
104
+
105
+ TERMS AND CONDITIONS
106
+
107
+ 0. Definitions.
108
+
109
+ "This License" refers to version 3 of the GNU General Public License.
110
+
111
+ "Copyright" also means copyright-like laws that apply to other kinds of
112
+ works, such as semiconductor masks.
113
+
114
+ "The Program" refers to any copyrightable work licensed under this
115
+ License. Each licensee is addressed as "you". "Licensees" and
116
+ "recipients" may be individuals or organizations.
117
+
118
+ To "modify" a work means to copy from or adapt all or part of the work
119
+ in a fashion requiring copyright permission, other than the making of an
120
+ exact copy. The resulting work is called a "modified version" of the
121
+ earlier work or a work "based on" the earlier work.
122
+
123
+ A "covered work" means either the unmodified Program or a work based
124
+ on the Program.
125
+
126
+ To "propagate" a work means to do anything with it that, without
127
+ permission, would make you directly or secondarily liable for
128
+ infringement under applicable copyright law, except executing it on a
129
+ computer or modifying a private copy. Propagation includes copying,
130
+ distribution (with or without modification), making available to the
131
+ public, and in some countries other activities as well.
132
+
133
+ To "convey" a work means any kind of propagation that enables other
134
+ parties to make or receive copies. Mere interaction with a user through
135
+ a computer network, with no transfer of a copy, is not conveying.
136
+
137
+ An interactive user interface displays "Appropriate Legal Notices"
138
+ to the extent that it includes a convenient and prominently visible
139
+ feature that (1) displays an appropriate copyright notice, and (2)
140
+ tells the user that there is no warranty for the work (except to the
141
+ extent that warranties are provided), that licensees may convey the
142
+ work under this License, and how to view a copy of this License. If
143
+ the interface presents a list of user commands or options, such as a
144
+ menu, a prominent item in the list meets this criterion.
145
+
146
+ 1. Source Code.
147
+
148
+ The "source code" for a work means the preferred form of the work
149
+ for making modifications to it. "Object code" means any non-source
150
+ form of a work.
151
+
152
+ A "Standard Interface" means an interface that either is an official
153
+ standard defined by a recognized standards body, or, in the case of
154
+ interfaces specified for a particular programming language, one that
155
+ is widely used among developers working in that language.
156
+
157
+ The "System Libraries" of an executable work include anything, other
158
+ than the work as a whole, that (a) is included in the normal form of
159
+ packaging a Major Component, but which is not part of that Major
160
+ Component, and (b) serves only to enable use of the work with that
161
+ Major Component, or to implement a Standard Interface for which an
162
+ implementation is available to the public in source code form. A
163
+ "Major Component", in this context, means a major essential component
164
+ (kernel, window system, and so on) of the specific operating system
165
+ (if any) on which the executable work runs, or a compiler used to
166
+ produce the work, or an object code interpreter used to run it.
167
+
168
+ The "Corresponding Source" for a work in object code form means all
169
+ the source code needed to generate, install, and (for an executable
170
+ work) run the object code and to modify the work, including scripts to
171
+ control those activities. However, it does not include the work's
172
+ System Libraries, or general-purpose tools or generally available free
173
+ programs which are used unmodified in performing those activities but
174
+ which are not part of the work. For example, Corresponding Source
175
+ includes interface definition files associated with source files for
176
+ the work, and the source code for shared libraries and dynamically
177
+ linked subprograms that the work is specifically designed to require,
178
+ such as by intimate data communication or control flow between those
179
+ subprograms and other parts of the work.
180
+
181
+ The Corresponding Source need not include anything that users
182
+ can regenerate automatically from other parts of the Corresponding
183
+ Source.
184
+
185
+ The Corresponding Source for a work in source code form is that
186
+ same work.
187
+
188
+ 2. Basic Permissions.
189
+
190
+ All rights granted under this License are granted for the term of
191
+ copyright on the Program, and are irrevocable provided the stated
192
+ conditions are met. This License explicitly affirms your unlimited
193
+ permission to run the unmodified Program. The output from running a
194
+ covered work is covered by this License only if the output, given its
195
+ content, constitutes a covered work. This License acknowledges your
196
+ rights of fair use or other equivalent, as provided by copyright law.
197
+
198
+ You may make, run and propagate covered works that you do not
199
+ convey, without conditions so long as your license otherwise remains
200
+ in force. You may convey covered works to others for the sole purpose
201
+ of having them make modifications exclusively for you, or provide you
202
+ with facilities for running those works, provided that you comply with
203
+ the terms of this License in conveying all material for which you do
204
+ not control copyright. Those thus making or running the covered works
205
+ for you must do so exclusively on your behalf, under your direction
206
+ and control, on terms that prohibit them from making any copies of
207
+ your copyrighted material outside their relationship with you.
208
+
209
+ Conveying under any other circumstances is permitted solely under
210
+ the conditions stated below. Sublicensing is not allowed; section 10
211
+ makes it unnecessary.
212
+
213
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
214
+
215
+ No covered work shall be deemed part of an effective technological
216
+ measure under any applicable law fulfilling obligations under article
217
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
218
+ similar laws prohibiting or restricting circumvention of such
219
+ measures.
220
+
221
+ When you convey a covered work, you waive any legal power to forbid
222
+ circumvention of technological measures to the extent such circumvention
223
+ is effected by exercising rights under this License with respect to
224
+ the covered work, and you disclaim any intention to limit operation or
225
+ modification of the work as a means of enforcing, against the work's
226
+ users, your or third parties' legal rights to forbid circumvention of
227
+ technological measures.
228
+
229
+ 4. Conveying Verbatim Copies.
230
+
231
+ You may convey verbatim copies of the Program's source code as you
232
+ receive it, in any medium, provided that you conspicuously and
233
+ appropriately publish on each copy an appropriate copyright notice;
234
+ keep intact all notices stating that this License and any
235
+ non-permissive terms added in accord with section 7 apply to the code;
236
+ keep intact all notices of the absence of any warranty; and give all
237
+ recipients a copy of this License along with the Program.
238
+
239
+ You may charge any price or no price for each copy that you convey,
240
+ and you may offer support or warranty protection for a fee.
241
+
242
+ 5. Conveying Modified Source Versions.
243
+
244
+ You may convey a work based on the Program, or the modifications to
245
+ produce it from the Program, in the form of source code under the
246
+ terms of section 4, provided that you also meet all of these conditions:
247
+
248
+ a) The work must carry prominent notices stating that you modified
249
+ it, and giving a relevant date.
250
+
251
+ b) The work must carry prominent notices stating that it is
252
+ released under this License and any conditions added under section
253
+ 7. This requirement modifies the requirement in section 4 to
254
+ "keep intact all notices".
255
+
256
+ c) You must license the entire work, as a whole, under this
257
+ License to anyone who comes into possession of a copy. This
258
+ License will therefore apply, along with any applicable section 7
259
+ additional terms, to the whole of the work, and all its parts,
260
+ regardless of how they are packaged. This License gives no
261
+ permission to license the work in any other way, but it does not
262
+ invalidate such permission if you have separately received it.
263
+
264
+ d) If the work has interactive user interfaces, each must display
265
+ Appropriate Legal Notices; however, if the Program has interactive
266
+ interfaces that do not display Appropriate Legal Notices, your
267
+ work need not make them do so.
268
+
269
+ A compilation of a covered work with other separate and independent
270
+ works, which are not by their nature extensions of the covered work,
271
+ and which are not combined with it such as to form a larger program,
272
+ in or on a volume of a storage or distribution medium, is called an
273
+ "aggregate" if the compilation and its resulting copyright are not
274
+ used to limit the access or legal rights of the compilation's users
275
+ beyond what the individual works permit. Inclusion of a covered work
276
+ in an aggregate does not cause this License to apply to the other
277
+ parts of the aggregate.
278
+
279
+ 6. Conveying Non-Source Forms.
280
+
281
+ You may convey a covered work in object code form under the terms
282
+ of sections 4 and 5, provided that you also convey the
283
+ machine-readable Corresponding Source under the terms of this License,
284
+ in one of these ways:
285
+
286
+ a) Convey the object code in, or embodied in, a physical product
287
+ (including a physical distribution medium), accompanied by the
288
+ Corresponding Source fixed on a durable physical medium
289
+ customarily used for software interchange.
290
+
291
+ b) Convey the object code in, or embodied in, a physical product
292
+ (including a physical distribution medium), accompanied by a
293
+ written offer, valid for at least three years and valid for as
294
+ long as you offer spare parts or customer support for that product
295
+ model, to give anyone who possesses the object code either (1) a
296
+ copy of the Corresponding Source for all the software in the
297
+ product that is covered by this License, on a durable physical
298
+ medium customarily used for software interchange, for a price no
299
+ more than your reasonable cost of physically performing this
300
+ conveying of source, or (2) access to copy the
301
+ Corresponding Source from a network server at no charge.
302
+
303
+ c) Convey individual copies of the object code with a copy of the
304
+ written offer to provide the Corresponding Source. This
305
+ alternative is allowed only occasionally and noncommercially, and
306
+ only if you received the object code with such an offer, in accord
307
+ with subsection 6b.
308
+
309
+ d) Convey the object code by offering access from a designated
310
+ place (gratis or for a charge), and offer equivalent access to the
311
+ Corresponding Source in the same way through the same place at no
312
+ further charge. You need not require recipients to copy the
313
+ Corresponding Source along with the object code. If the place to
314
+ copy the object code is a network server, the Corresponding Source
315
+ may be on a different server (operated by you or a third party)
316
+ that supports equivalent copying facilities, provided you maintain
317
+ clear directions next to the object code saying where to find the
318
+ Corresponding Source. Regardless of what server hosts the
319
+ Corresponding Source, you remain obligated to ensure that it is
320
+ available for as long as needed to satisfy these requirements.
321
+
322
+ e) Convey the object code using peer-to-peer transmission, provided
323
+ you inform other peers where the object code and Corresponding
324
+ Source of the work are being offered to the general public at no
325
+ charge under subsection 6d.
326
+
327
+ A separable portion of the object code, whose source code is excluded
328
+ from the Corresponding Source as a System Library, need not be
329
+ included in conveying the object code work.
330
+
331
+ A "User Product" is either (1) a "consumer product", which means any
332
+ tangible personal property which is normally used for personal, family,
333
+ or household purposes, or (2) anything designed or sold for incorporation
334
+ into a dwelling. In determining whether a product is a consumer product,
335
+ doubtful cases shall be resolved in favor of coverage. For a particular
336
+ product received by a particular user, "normally used" refers to a
337
+ typical or common use of that class of product, regardless of the status
338
+ of the particular user or of the way in which the particular user
339
+ actually uses, or expects or is expected to use, the product. A product
340
+ is a consumer product regardless of whether the product has substantial
341
+ commercial, industrial or non-consumer uses, unless such uses represent
342
+ the only significant mode of use of the product.
343
+
344
+ "Installation Information" for a User Product means any methods,
345
+ procedures, authorization keys, or other information required to install
346
+ and execute modified versions of a covered work in that User Product from
347
+ a modified version of its Corresponding Source. The information must
348
+ suffice to ensure that the continued functioning of the modified object
349
+ code is in no case prevented or interfered with solely because
350
+ modification has been made.
351
+
352
+ If you convey an object code work under this section in, or with, or
353
+ specifically for use in, a User Product, and the conveying occurs as
354
+ part of a transaction in which the right of possession and use of the
355
+ User Product is transferred to the recipient in perpetuity or for a
356
+ fixed term (regardless of how the transaction is characterized), the
357
+ Corresponding Source conveyed under this section must be accompanied
358
+ by the Installation Information. But this requirement does not apply
359
+ if neither you nor any third party retains the ability to install
360
+ modified object code on the User Product (for example, the work has
361
+ been installed in ROM).
362
+
363
+ The requirement to provide Installation Information does not include a
364
+ requirement to continue to provide support service, warranty, or updates
365
+ for a work that has been modified or installed by the recipient, or for
366
+ the User Product in which it has been modified or installed. Access to a
367
+ network may be denied when the modification itself materially and
368
+ adversely affects the operation of the network or violates the rules and
369
+ protocols for communication across the network.
370
+
371
+ Corresponding Source conveyed, and Installation Information provided,
372
+ in accord with this section must be in a format that is publicly
373
+ documented (and with an implementation available to the public in
374
+ source code form), and must require no special password or key for
375
+ unpacking, reading or copying.
376
+
377
+ 7. Additional Terms.
378
+
379
+ "Additional permissions" are terms that supplement the terms of this
380
+ License by making exceptions from one or more of its conditions.
381
+ Additional permissions that are applicable to the entire Program shall
382
+ be treated as though they were included in this License, to the extent
383
+ that they are valid under applicable law. If additional permissions
384
+ apply only to part of the Program, that part may be used separately
385
+ under those permissions, but the entire Program remains governed by
386
+ this License without regard to the additional permissions.
387
+
388
+ When you convey a copy of a covered work, you may at your option
389
+ remove any additional permissions from that copy, or from any part of
390
+ it. (Additional permissions may be written to require their own
391
+ removal in certain cases when you modify the work.) You may place
392
+ additional permissions on material, added by you to a covered work,
393
+ for which you have or can give appropriate copyright permission.
394
+
395
+ Notwithstanding any other provision of this License, for material you
396
+ add to a covered work, you may (if authorized by the copyright holders of
397
+ that material) supplement the terms of this License with terms:
398
+
399
+ a) Disclaiming warranty or limiting liability differently from the
400
+ terms of sections 15 and 16 of this License; or
401
+
402
+ b) Requiring preservation of specified reasonable legal notices or
403
+ author attributions in that material or in the Appropriate Legal
404
+ Notices displayed by works containing it; or
405
+
406
+ c) Prohibiting misrepresentation of the origin of that material, or
407
+ requiring that modified versions of such material be marked in
408
+ reasonable ways as different from the original version; or
409
+
410
+ d) Limiting the use for publicity purposes of names of licensors or
411
+ authors of the material; or
412
+
413
+ e) Declining to grant rights under trademark law for use of some
414
+ trade names, trademarks, or service marks; or
415
+
416
+ f) Requiring indemnification of licensors and authors of that
417
+ material by anyone who conveys the material (or modified versions of
418
+ it) with contractual assumptions of liability to the recipient, for
419
+ any liability that these contractual assumptions directly impose on
420
+ those licensors and authors.
421
+
422
+ All other non-permissive additional terms are considered "further
423
+ restrictions" within the meaning of section 10. If the Program as you
424
+ received it, or any part of it, contains a notice stating that it is
425
+ governed by this License along with a term that is a further
426
+ restriction, you may remove that term. If a license document contains
427
+ a further restriction but permits relicensing or conveying under this
428
+ License, you may add to a covered work material governed by the terms
429
+ of that license document, provided that the further restriction does
430
+ not survive such relicensing or conveying.
431
+
432
+ If you add terms to a covered work in accord with this section, you
433
+ must place, in the relevant source files, a statement of the
434
+ additional terms that apply to those files, or a notice indicating
435
+ where to find the applicable terms.
436
+
437
+ Additional terms, permissive or non-permissive, may be stated in the
438
+ form of a separately written license, or stated as exceptions;
439
+ the above requirements apply either way.
440
+
441
+ 8. Termination.
442
+
443
+ You may not propagate or modify a covered work except as expressly
444
+ provided under this License. Any attempt otherwise to propagate or
445
+ modify it is void, and will automatically terminate your rights under
446
+ this License (including any patent licenses granted under the third
447
+ paragraph of section 11).
448
+
449
+ However, if you cease all violation of this License, then your
450
+ license from a particular copyright holder is reinstated (a)
451
+ provisionally, unless and until the copyright holder explicitly and
452
+ finally terminates your license, and (b) permanently, if the copyright
453
+ holder fails to notify you of the violation by some reasonable means
454
+ prior to 60 days after the cessation.
455
+
456
+ Moreover, your license from a particular copyright holder is
457
+ reinstated permanently if the copyright holder notifies you of the
458
+ violation by some reasonable means, this is the first time you have
459
+ received notice of violation of this License (for any work) from that
460
+ copyright holder, and you cure the violation prior to 30 days after
461
+ your receipt of the notice.
462
+
463
+ Termination of your rights under this section does not terminate the
464
+ licenses of parties who have received copies or rights from you under
465
+ this License. If your rights have been terminated and not permanently
466
+ reinstated, you do not qualify to receive new licenses for the same
467
+ material under section 10.
468
+
469
+ 9. Acceptance Not Required for Having Copies.
470
+
471
+ You are not required to accept this License in order to receive or
472
+ run a copy of the Program. Ancillary propagation of a covered work
473
+ occurring solely as a consequence of using peer-to-peer transmission
474
+ to receive a copy likewise does not require acceptance. However,
475
+ nothing other than this License grants you permission to propagate or
476
+ modify any covered work. These actions infringe copyright if you do
477
+ not accept this License. Therefore, by modifying or propagating a
478
+ covered work, you indicate your acceptance of this License to do so.
479
+
480
+ 10. Automatic Licensing of Downstream Recipients.
481
+
482
+ Each time you convey a covered work, the recipient automatically
483
+ receives a license from the original licensors, to run, modify and
484
+ propagate that work, subject to this License. You are not responsible
485
+ for enforcing compliance by third parties with this License.
486
+
487
+ An "entity transaction" is a transaction transferring control of an
488
+ organization, or substantially all assets of one, or subdividing an
489
+ organization, or merging organizations. If propagation of a covered
490
+ work results from an entity transaction, each party to that
491
+ transaction who receives a copy of the work also receives whatever
492
+ licenses to the work the party's predecessor in interest had or could
493
+ give under the previous paragraph, plus a right to possession of the
494
+ Corresponding Source of the work from the predecessor in interest, if
495
+ the predecessor has it or can get it with reasonable efforts.
496
+
497
+ You may not impose any further restrictions on the exercise of the
498
+ rights granted or affirmed under this License. For example, you may
499
+ not impose a license fee, royalty, or other charge for exercise of
500
+ rights granted under this License, and you may not initiate litigation
501
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
502
+ any patent claim is infringed by making, using, selling, offering for
503
+ sale, or importing the Program or any portion of it.
504
+
505
+ 11. Patents.
506
+
507
+ A "contributor" is a copyright holder who authorizes use under this
508
+ License of the Program or a work on which the Program is based. The
509
+ work thus licensed is called the contributor's "contributor version".
510
+
511
+ A contributor's "essential patent claims" are all patent claims
512
+ owned or controlled by the contributor, whether already acquired or
513
+ hereafter acquired, that would be infringed by some manner, permitted
514
+ by this License, of making, using, or selling its contributor version,
515
+ but do not include claims that would be infringed only as a
516
+ consequence of further modification of the contributor version. For
517
+ purposes of this definition, "control" includes the right to grant
518
+ patent sublicenses in a manner consistent with the requirements of
519
+ this License.
520
+
521
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
522
+ patent license under the contributor's essential patent claims, to
523
+ make, use, sell, offer for sale, import and otherwise run, modify and
524
+ propagate the contents of its contributor version.
525
+
526
+ In the following three paragraphs, a "patent license" is any express
527
+ agreement or commitment, however denominated, not to enforce a patent
528
+ (such as an express permission to practice a patent or covenant not to
529
+ sue for patent infringement). To "grant" such a patent license to a
530
+ party means to make such an agreement or commitment not to enforce a
531
+ patent against the party.
532
+
533
+ If you convey a covered work, knowingly relying on a patent license,
534
+ and the Corresponding Source of the work is not available for anyone
535
+ to copy, free of charge and under the terms of this License, through a
536
+ publicly available network server or other readily accessible means,
537
+ then you must either (1) cause the Corresponding Source to be so
538
+ available, or (2) arrange to deprive yourself of the benefit of the
539
+ patent license for this particular work, or (3) arrange, in a manner
540
+ consistent with the requirements of this License, to extend the patent
541
+ license to downstream recipients. "Knowingly relying" means you have
542
+ actual knowledge that, but for the patent license, your conveying the
543
+ covered work in a country, or your recipient's use of the covered work
544
+ in a country, would infringe one or more identifiable patents in that
545
+ country that you have reason to believe are valid.
546
+
547
+ If, pursuant to or in connection with a single transaction or
548
+ arrangement, you convey, or propagate by procuring conveyance of, a
549
+ covered work, and grant a patent license to some of the parties
550
+ receiving the covered work authorizing them to use, propagate, modify
551
+ or convey a specific copy of the covered work, then the patent license
552
+ you grant is automatically extended to all recipients of the covered
553
+ work and works based on it.
554
+
555
+ A patent license is "discriminatory" if it does not include within
556
+ the scope of its coverage, prohibits the exercise of, or is
557
+ conditioned on the non-exercise of one or more of the rights that are
558
+ specifically granted under this License. You may not convey a covered
559
+ work if you are a party to an arrangement with a third party that is
560
+ in the business of distributing software, under which you make payment
561
+ to the third party based on the extent of your activity of conveying
562
+ the work, and under which the third party grants, to any of the
563
+ parties who would receive the covered work from you, a discriminatory
564
+ patent license (a) in connection with copies of the covered work
565
+ conveyed by you (or copies made from those copies), or (b) primarily
566
+ for and in connection with specific products or compilations that
567
+ contain the covered work, unless you entered into that arrangement,
568
+ or that patent license was granted, prior to 28 March 2007.
569
+
570
+ Nothing in this License shall be construed as excluding or limiting
571
+ any implied license or other defenses to infringement that may
572
+ otherwise be available to you under applicable patent law.
573
+
574
+ 12. No Surrender of Others' Freedom.
575
+
576
+ If conditions are imposed on you (whether by court order, agreement or
577
+ otherwise) that contradict the conditions of this License, they do not
578
+ excuse you from the conditions of this License. If you cannot convey a
579
+ covered work so as to satisfy simultaneously your obligations under this
580
+ License and any other pertinent obligations, then as a consequence you may
581
+ not convey it at all. For example, if you agree to terms that obligate you
582
+ to collect a royalty for further conveying from those to whom you convey
583
+ the Program, the only way you could satisfy both those terms and this
584
+ License would be to refrain entirely from conveying the Program.
585
+
586
+ 13. Use with the GNU Affero General Public License.
587
+
588
+ Notwithstanding any other provision of this License, you have
589
+ permission to link or combine any covered work with a work licensed
590
+ under version 3 of the GNU Affero General Public License into a single
591
+ combined work, and to convey the resulting work. The terms of this
592
+ License will continue to apply to the part which is the covered work,
593
+ but the special requirements of the GNU Affero General Public License,
594
+ section 13, concerning interaction through a network will apply to the
595
+ combination as such.
596
+
597
+ 14. Revised Versions of this License.
598
+
599
+ The Free Software Foundation may publish revised and/or new versions of
600
+ the GNU General Public License from time to time. Such new versions will
601
+ be similar in spirit to the present version, but may differ in detail to
602
+ address new problems or concerns.
603
+
604
+ Each version is given a distinguishing version number. If the
605
+ Program specifies that a certain numbered version of the GNU General
606
+ Public License "or any later version" applies to it, you have the
607
+ option of following the terms and conditions either of that numbered
608
+ version or of any later version published by the Free Software
609
+ Foundation. If the Program does not specify a version number of the
610
+ GNU General Public License, you may choose any version ever published
611
+ by the Free Software Foundation.
612
+
613
+ If the Program specifies that a proxy can decide which future
614
+ versions of the GNU General Public License can be used, that proxy's
615
+ public statement of acceptance of a version permanently authorizes you
616
+ to choose that version for the Program.
617
+
618
+ Later license versions may give you additional or different
619
+ permissions. However, no additional obligations are imposed on any
620
+ author or copyright holder as a result of your choosing to follow a
621
+ later version.
622
+
623
+ 15. Disclaimer of Warranty.
624
+
625
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
626
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
627
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
628
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
629
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
630
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
631
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
632
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
633
+
634
+ 16. Limitation of Liability.
635
+
636
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
637
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
638
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
639
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
640
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
641
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
642
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
643
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
644
+ SUCH DAMAGES.
645
+
646
+ 17. Interpretation of Sections 15 and 16.
647
+
648
+ If the disclaimer of warranty and limitation of liability provided
649
+ above cannot be given local legal effect according to their terms,
650
+ reviewing courts shall apply local law that most closely approximates
651
+ an absolute waiver of all civil liability in connection with the
652
+ Program, unless a warranty or assumption of liability accompanies a
653
+ copy of the Program in return for a fee.
654
+
655
+ END OF TERMS AND CONDITIONS
656
+
657
+ How to Apply These Terms to Your New Programs
658
+
659
+ If you develop a new program, and you want it to be of the greatest
660
+ possible use to the public, the best way to achieve this is to make it
661
+ free software which everyone can redistribute and change under these terms.
662
+
663
+ To do so, attach the following notices to the program. It is safest
664
+ to attach them to the start of each source file to most effectively
665
+ state the exclusion of warranty; and each file should have at least
666
+ the "copyright" line and a pointer to where the full notice is found.
667
+
668
+ <one line to give the program's name and a brief idea of what it does.>
669
+ Copyright © <year> <name of author>
670
+
671
+ This program is free software: you can redistribute it and/or modify
672
+ it under the terms of the GNU General Public License as published by
673
+ the Free Software Foundation, either version 3 of the License, or
674
+ (at your option) any later version.
675
+
676
+ This program is distributed in the hope that it will be useful,
677
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
678
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
679
+ GNU General Public License for more details.
680
+
681
+ You should have received a copy of the GNU General Public License
682
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
683
+
684
+ Also add information on how to contact you by electronic and paper mail.
685
+
686
+ If the program does terminal interaction, make it output a short
687
+ notice like this when it starts in an interactive mode:
688
+
689
+ <program> Copyright © <year> <name of author>
690
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
691
+ This is free software, and you are welcome to redistribute it
692
+ under certain conditions; type `show c' for details.
693
+
694
+ The hypothetical commands `show w' and `show c' should show the appropriate
695
+ parts of the General Public License. Of course, your program's commands
696
+ might be different; for a GUI interface, you would use an "about box".
697
+
698
+ You should also get your employer (if you work as a programmer) or school,
699
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
700
+ For more information on this, and how to apply and follow the GNU GPL, see
701
+ <http://www.gnu.org/licenses/>.
702
+
703
+ The GNU General Public License does not permit incorporating your program
704
+ into proprietary programs. If your program is a subroutine library, you
705
+ may consider it more useful to permit linking proprietary applications with
706
+ the library. If this is what you want to do, use the GNU Lesser General
707
+ Public License instead of this License. But first, please read
708
+ <http://www.gnu.org/philosophy/why-not-lgpl.html>.
package.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "woocommerceproductsblock",
3
+ "title": "WooCommerce Products Block",
4
+ "version": "3.3.0",
5
+ "homepage": "https://woocommerce.com/",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com:woocommerce/woocommerce-gutenberg-products-block.git"
9
+ },
10
+ "license": "GPL-3.0+",
11
+ "main": "Gruntfile.js",
12
+ "scripts": {
13
+ "build-gutenberg": "cross-env BABEL_ENV=default NODE_ENV=production webpack",
14
+ "build-gutenberg-watch": "cross-env BABEL_ENV=default webpack --watch"
15
+ },
16
+ "devDependencies": {
17
+ "autoprefixer": "~7.1.6",
18
+ "babel": "^6.5.2",
19
+ "babel-cli": "^6.14.0",
20
+ "babel-core": "6.25.0",
21
+ "babel-eslint": "^7.0.0",
22
+ "babel-loader": "^7.1.1",
23
+ "babel-plugin-transform-react-jsx": "^6.24.1",
24
+ "babel-plugin-add-module-exports": "^0.2.1",
25
+ "babel-preset-env": "^1.6.0",
26
+ "babel-preset-es2015": "^6.14.0",
27
+ "babel-preset-stage-2": "^6.13.0",
28
+ "config": "^1.24.0",
29
+ "cross-env": "~5.1.1",
30
+ "grunt": "~1.0.1",
31
+ "grunt-checktextdomain": "~1.0.1",
32
+ "grunt-contrib-clean": "~1.1.0",
33
+ "grunt-contrib-concat": "~1.0.1",
34
+ "grunt-contrib-cssmin": "~2.2.1",
35
+ "grunt-contrib-jshint": "~1.1.0",
36
+ "grunt-contrib-uglify": "~3.1.0",
37
+ "grunt-contrib-watch": "~1.0.0",
38
+ "grunt-phpcs": "~0.4.0",
39
+ "grunt-postcss": "~0.9.0",
40
+ "grunt-rtlcss": "~2.0.1",
41
+ "grunt-sass": "~2.0.0",
42
+ "grunt-shell": "~2.1.0",
43
+ "grunt-stylelint": "~0.9.0",
44
+ "grunt-wp-i18n": "~1.0.1",
45
+ "stylelint": "~8.2.0",
46
+ "webpack": "^3.1.0"
47
+ },
48
+ "engines": {
49
+ "node": ">=8.9.3",
50
+ "npm": ">=5.5.1"
51
+ }
52
+ }
readme.txt ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WooCommerce Gutenberg Products Block ===
2
+ Contributors: automattic, claudiulodro, tiagonoronha, jameskoster
3
+ Tags: gutenberg, woocommerce, woo commerce, products
4
+ Requires at least: 4.7
5
+ Tested up to: 4.9
6
+ Requires PHP: 5.2
7
+ Stable tag: 1.0.0
8
+ License: GPLv3
9
+ License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
+
11
+ == Description ==
12
+
13
+ The WooCommerce Gutenberg Products block is a new block for the Gutenberg post editor. This block is a custom products area that features your WooCommerce products. The products featured can be filtered by categories, sale status, or a variety of other fields, and you can even make a custom list of hand-picked products to display. The Products block is the easiest and most flexible way to feature your products on your posts and pages!
14
+
15
+ == Getting Started ==
16
+
17
+ = Minimum Requirements =
18
+
19
+ * The latest version of the Gutenberg plugin
20
+ * WooCommerce 3.3.0 or greater
21
+ * PHP version 5.2.4 or greater (PHP 7.2 or greater is recommended)
22
+ * MySQL version 5.0 or greater (MySQL 5.6 or greater is recommended)
23
+
24
+ Visit the [WooCommerce server requirements documentation](https://docs.woocommerce.com/document/server-requirements/) for a detailed list of server requirements.
25
+
26
+ = Automatic installation =
27
+
28
+ Automatic installation is the easiest option as WordPress handles the file transfers itself and you don’t need to leave your web browser. To do an automatic install of this plugin, log in to your WordPress dashboard, navigate to the Plugins menu and click Add New.
29
+
30
+ In the search field type “WooCommerce Gutenberg Products Block” and click Search Plugins. Once you’ve found this plugin you can view details about it such as the point release, rating and description. Most importantly of course, you can install it by simply clicking “Install Now”.
31
+
32
+ = Manual installation =
33
+
34
+ The manual installation method involves downloading the plugin and uploading it to your webserver via your favourite FTP application. The WordPress codex contains [instructions on how to do this here](https://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation).
35
+
36
+ = Sample data =
37
+
38
+ WooCommerce comes with some sample data you can use to populate the products and get started building Products blocks quickly and easily. You can use the core [CSV importer](https://docs.woocommerce.com/document/product-csv-importer-exporter/) or our [CSV Import Suite plugin](https://woocommerce.com/products/product-csv-import-suite/) to import sample_products.csv.
39
+
40
+ = Where can I report bugs or contribute to the project? =
41
+
42
+ Bugs should be reported in the [WooCommerce Gutenberg Products Block GitHub repository](https://github.com/woocommerce/woocommerce-gutenberg-products-block/).
43
+
44
+ = This is awesome! Can I contribute? =
45
+
46
+ Yes you can! Join in on our [GitHub repository](https://github.com/woocommerce/woocommerce-gutenberg-products-block/) :)
47
+
48
+ == Screenshots ==
49
+
50
+ 1. The initial Products block.
51
+ 2. Selecting hand-picked products for the Products block.
52
+ 3. The completed Products block when inserted into a post.
53
+
54
+ == Changelog ==
55
+
56
+ = 1.0.0 - 2018-04-24 =
57
+ * Initial implementation of the Gutenberg Products block.
58
+
59
+ == Upgrade Notice ==
60
+
61
+ = 1.0 =
webpack.config.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Config for compiling Gutenberg blocks JS.
3
+ */
4
+ var GutenbergBlocksConfig = {
5
+ entry: {
6
+ 'products-block': './assets/js/products-block.jsx',
7
+ // 'next-block-name': './assets/js/gutenberg/some-other-block.jsx', <-- How to add more gutenblocks to this.
8
+ },
9
+ output: {
10
+ path: __dirname + '/assets/js/',
11
+ filename: '[name].js',
12
+ },
13
+ module: {
14
+ loaders: [
15
+ {
16
+ test: /.jsx$/,
17
+ loader: 'babel-loader',
18
+ exclude: /node_modules/,
19
+ },
20
+ ],
21
+ },
22
+ };
23
+
24
+ module.exports = [ GutenbergBlocksConfig ];
woocommerce-gutenberg-products-block.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: WooCommerce Gutenberg Products Block
4
+ * Plugin URI: https://github.com/woocommerce/woocommerce-gutenberg-products-block
5
+ * Description: WooCommerce Products block for the Gutenberg editor.
6
+ * Version: 1.0.0
7
+ * Author: Automattic
8
+ * Author URI: https://woocommerce.com
9
+ * Text Domain: woocommerce
10
+ * Domain Path: /languages
11
+ */
12
+
13
+ defined( 'ABSPATH' ) || die();
14
+
15
+ define( 'WGPB_VERSION', '1.0.0' );
16
+
17
+ /**
18
+ * Load up the assets if Gutenberg is active.
19
+ */
20
+ function wgpb_initialize() {
21
+
22
+ if ( function_exists( 'register_block_type' ) ) {
23
+ add_action( 'init', 'wgpb_register_products_block' );
24
+ }
25
+
26
+ }
27
+ add_action( 'woocommerce_loaded', 'wgpb_initialize' );
28
+
29
+ /**
30
+ * Register the Products block and its scripts.
31
+ */
32
+ function wgpb_register_products_block() {
33
+ wp_register_script(
34
+ 'woocommerce-products-block-editor',
35
+ plugins_url( 'assets/js/products-block.js', __FILE__ ),
36
+ array( 'wp-blocks', 'wp-element', 'react-transition-group' ),
37
+ WGPB_VERSION
38
+ );
39
+
40
+ $product_block_data = array(
41
+ 'min_columns' => wc_get_theme_support( 'product_grid::min_columns', 1 ),
42
+ 'max_columns' => wc_get_theme_support( 'product_grid::max_columns', 6 ),
43
+ 'default_columns' => wc_get_default_products_per_row(),
44
+ 'min_rows' => wc_get_theme_support( 'product_grid::min_rows', 1 ),
45
+ 'max_rows' => wc_get_theme_support( 'product_grid::max_rows', 6 ),
46
+ 'default_rows' => wc_get_default_product_rows_per_page(),
47
+ );
48
+ wp_localize_script( 'woocommerce-products-block-editor', 'wc_product_block_data', $product_block_data );
49
+
50
+ wp_register_style(
51
+ 'woocommerce-products-block-editor',
52
+ plugins_url( 'assets/css/gutenberg-products-block.css', __FILE__ ),
53
+ array( 'wp-edit-blocks' ),
54
+ WGPB_VERSION
55
+ );
56
+
57
+ register_block_type( 'woocommerce/products', array(
58
+ 'editor_script' => 'woocommerce-products-block-editor',
59
+ 'editor_style' => 'woocommerce-products-block-editor',
60
+ ) );
61
+ }
62
+
63
+ /**
64
+ * Register extra scripts needed.
65
+ */
66
+ function wgpb_extra_gutenberg_scripts() {
67
+ wp_enqueue_script(
68
+ 'react-transition-group',
69
+ plugins_url( 'assets/js/vendor/react-transition-group.js', __FILE__ ),
70
+ array( 'wp-blocks', 'wp-element' ),
71
+ '2.2.1'
72
+ );
73
+ }
74
+ add_action( 'enqueue_block_assets', 'wgpb_extra_gutenberg_scripts' );
75
+
76
+ /**
77
+ * Brings some extra required shortcode features from WC core 3.4+ to this feature plugin.
78
+ *
79
+ * @todo Remove this function when merging into core because it won't be necessary.
80
+ *
81
+ * @param array $args WP_Query args.
82
+ * @param array $attributes Shortcode attributes.
83
+ * @param string $type Type of shortcode currently processing.
84
+ */
85
+ function wgpb_extra_shortcode_features( $args, $attributes, $type ) {
86
+ if ( 'products' !== $type ) {
87
+ return $args;
88
+ }
89
+
90
+ // Enable term ids in the category shortcode.
91
+ if ( ! empty( $attributes['category'] ) ) {
92
+ $categories = array_map( 'sanitize_title', explode( ',', $attributes['category'] ) );
93
+ $field = 'slug';
94
+
95
+ if ( empty( $args['tax_query'] ) ) {
96
+ $args['tax_query'] = array();
97
+ }
98
+
99
+ // Unset old category tax query.
100
+ foreach ( $args['tax_query'] as $index => $tax_query ) {
101
+ if ( 'product_cat' === $tax_query['taxonomy'] ) {
102
+ unset( $args['tax_query'][ $index ] );
103
+ }
104
+ }
105
+
106
+ if ( is_numeric( $categories[0] ) ) {
107
+ $categories = array_map( 'absint', $categories );
108
+ $field = 'term_id';
109
+ }
110
+ $args['tax_query'][] = array(
111
+ 'taxonomy' => 'product_cat',
112
+ 'terms' => $categories,
113
+ 'field' => $field,
114
+ 'operator' => $attributes['cat_operator'],
115
+ );
116
+ }
117
+
118
+ // Enable term ids in the attributes shortcode and just-attribute queries.
119
+ if ( ! empty( $attributes['attribute'] ) || ! empty( $attributes['terms'] ) ) {
120
+ $taxonomy = strstr( $attributes['attribute'], 'pa_' ) ? sanitize_title( $attributes['attribute'] ) : 'pa_' . sanitize_title( $attributes['attribute'] );
121
+ $terms = $attributes['terms'] ? array_map( 'sanitize_title', explode( ',', $attributes['terms'] ) ) : array();
122
+ $field = 'slug';
123
+
124
+ if ( empty( $args['tax_query'] ) ) {
125
+ $args['tax_query'] = array();
126
+ }
127
+
128
+ // Unset old attribute tax query.
129
+ foreach ( $args['tax_query'] as $index => $tax_query ) {
130
+ if ( $taxonomy === $tax_query['taxonomy'] ) {
131
+ unset( $args['tax_query'][ $index ] );
132
+ }
133
+ }
134
+
135
+ if ( $terms && is_numeric( $terms[0] ) ) {
136
+ $terms = array_map( 'absint', $terms );
137
+ $field = 'term_id';
138
+ }
139
+
140
+ // If no terms were specified get all products that are in the attribute taxonomy.
141
+ if ( ! $terms ) {
142
+ $terms = get_terms(
143
+ array(
144
+ 'taxonomy' => $taxonomy,
145
+ 'fields' => 'ids',
146
+ )
147
+ );
148
+ $field = 'term_id';
149
+ }
150
+
151
+ $args['tax_query'][] = array(
152
+ 'taxonomy' => $taxonomy,
153
+ 'terms' => $terms,
154
+ 'field' => $field,
155
+ 'operator' => $attributes['terms_operator'],
156
+ );
157
+ }
158
+
159
+ return $args;
160
+ }
161
+ add_filter( 'woocommerce_shortcode_products_query', 'wgpb_extra_shortcode_features', 10, 3 );