newspack-components 3.0.0-alpha.2 → 3.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.config.cjs.js +26 -0
- package/babel.config.js +1 -0
- package/copy-styles.js +10 -2
- package/dist/esm/accordion/index.js +42 -0
- package/dist/esm/accordion/style.scss +31 -0
- package/dist/esm/action-card/index.js +218 -0
- package/dist/esm/action-card/style.scss +483 -0
- package/dist/esm/autocomplete-tokenfield/index.js +261 -0
- package/dist/esm/autocomplete-tokenfield/style.scss +49 -0
- package/dist/esm/autocomplete-with-suggestions/index.js +274 -0
- package/dist/esm/autocomplete-with-suggestions/style.scss +163 -0
- package/dist/esm/button/style.scss +11 -0
- package/dist/esm/button-card/index.js +64 -0
- package/dist/esm/button-card/style.scss +180 -0
- package/dist/esm/card/index.js +43 -0
- package/dist/esm/card/style.scss +168 -0
- package/dist/esm/category-autocomplete/index.js +183 -0
- package/dist/esm/category-autocomplete/style.scss +34 -0
- package/dist/esm/color-picker/index.js +59 -0
- package/dist/esm/color-picker/style.scss +37 -0
- package/dist/esm/consts.js +1 -0
- package/dist/esm/custom-select-control/index.js +37 -0
- package/dist/esm/custom-select-control/style.scss +93 -0
- package/dist/esm/date-range-picker/index.js +31 -0
- package/dist/esm/date-range-picker/style.scss +148 -0
- package/dist/esm/footer/index.js +99 -0
- package/dist/esm/footer/style.scss +82 -0
- package/dist/esm/form-token-field/index.js +49 -0
- package/dist/esm/form-token-field/style.scss +37 -0
- package/dist/esm/global-notices/index.js +30 -0
- package/dist/esm/grid/style.scss +166 -0
- package/dist/esm/handoff/index.js +175 -0
- package/dist/esm/handoff-message/index.js +47 -0
- package/dist/esm/hooks/useObjectState.js +30 -0
- package/dist/esm/hooks/useObjectState.test.js +82 -0
- package/dist/esm/hooks/useOnClickOutside.js +31 -0
- package/dist/esm/image-upload/index.js +140 -0
- package/dist/esm/image-upload/index.test.js +34 -0
- package/dist/esm/image-upload/style.scss +103 -0
- package/dist/esm/index.js +47 -0
- package/dist/esm/info-button/index.js +42 -0
- package/dist/esm/info-button/style.scss +18 -0
- package/dist/esm/modal/index.js +39 -0
- package/dist/esm/modal/style.scss +56 -0
- package/dist/esm/newspack-icon/index.js +50 -0
- package/dist/esm/newspack-icon/style.scss +26 -0
- package/dist/esm/newspack-logo/index.js +46 -0
- package/dist/esm/newspack-logo/style.scss +30 -0
- package/dist/esm/notice/index.js +65 -0
- package/dist/esm/notice/style.scss +111 -0
- package/dist/esm/patrons-logo/index.js +70 -0
- package/dist/esm/plugin-installer/index.js +289 -0
- package/dist/esm/plugin-installer/style.scss +72 -0
- package/dist/esm/plugin-settings/SettingsSection.js +133 -0
- package/dist/esm/plugin-settings/index.js +220 -0
- package/dist/esm/plugin-settings/style.scss +7 -0
- package/dist/esm/plugin-toggle/index.js +216 -0
- package/dist/esm/plugin-toggle/style.scss +20 -0
- package/dist/esm/popover/index.js +41 -0
- package/dist/esm/popover/style.scss +161 -0
- package/dist/esm/position-control/index.js +106 -0
- package/dist/esm/position-control/style.scss +66 -0
- package/dist/esm/progress-bar/index.js +68 -0
- package/dist/esm/progress-bar/index.test.js +108 -0
- package/dist/esm/progress-bar/style.scss +42 -0
- package/dist/esm/proxied-imports/router.js +8 -0
- package/dist/esm/radio-control/index.js +37 -0
- package/dist/esm/radio-control/style.scss +92 -0
- package/dist/esm/section-header/index.js +67 -0
- package/dist/esm/section-header/style.scss +45 -0
- package/dist/esm/select-control/ButtonGroupControl.js +53 -0
- package/dist/esm/select-control/GroupedSelectControl.js +78 -0
- package/dist/esm/select-control/index.js +51 -0
- package/dist/esm/select-control/style.scss +108 -0
- package/dist/esm/settings/MinMaxSetting.js +53 -0
- package/dist/esm/settings/SettingsCard.js +38 -0
- package/dist/esm/settings/SettingsSection.js +26 -0
- package/dist/esm/settings/index.js +9 -0
- package/dist/esm/settings/style.scss +119 -0
- package/dist/esm/sortable-newsletter-list-control/index.js +127 -0
- package/dist/esm/sortable-newsletter-list-control/style.scss +45 -0
- package/dist/esm/steps-list/index.js +43 -0
- package/dist/esm/steps-list/style.scss +11 -0
- package/dist/esm/steps-list-item/index.js +47 -0
- package/dist/esm/steps-list-item/style.scss +47 -0
- package/dist/esm/style-card/index.js +74 -0
- package/dist/esm/style-card/style.scss +94 -0
- package/dist/esm/style.scss +55 -0
- package/dist/esm/tabbed-navigation/index.js +53 -0
- package/dist/esm/tabbed-navigation/style.scss +86 -0
- package/dist/esm/text-control/style.scss +32 -0
- package/dist/esm/utils/index.js +29 -0
- package/dist/esm/waiting/index.js +44 -0
- package/dist/esm/waiting/style.scss +27 -0
- package/dist/esm/web-preview/index.js +183 -0
- package/dist/esm/web-preview/style.scss +155 -0
- package/dist/esm/with-wizard/index.js +320 -0
- package/dist/esm/with-wizard/style.scss +282 -0
- package/dist/esm/with-wizard-screen/index.js +109 -0
- package/dist/esm/with-wizard-screen/style.scss +160 -0
- package/dist/esm/wizard/components/WizardError.js +66 -0
- package/dist/esm/wizard/index.js +119 -0
- package/dist/esm/wizard/store/index.js +155 -0
- package/dist/esm/wizard/store/utils.js +14 -0
- package/package.json +7 -4
- package/dist/button/index.js +0 -51
- package/dist/button/index.tsx +0 -48
- package/dist/grid/index.js +0 -44
- package/dist/grid/index.tsx +0 -34
- package/dist/hooks/index.js +0 -29
- package/dist/hooks/index.ts +0 -15
- package/dist/hooks/usePrompt.js +0 -47
- package/dist/hooks/usePrompt.ts +0 -46
- package/dist/plugin-toggle/README.md +0 -53
- package/dist/text-control/index.js +0 -76
- package/dist/text-control/index.tsx +0 -71
- /package/dist/{accordion → cjs/accordion}/index.js +0 -0
- /package/dist/{accordion → cjs/accordion}/style.scss +0 -0
- /package/dist/{action-card → cjs/action-card}/index.js +0 -0
- /package/dist/{action-card → cjs/action-card}/style.scss +0 -0
- /package/dist/{autocomplete-tokenfield → cjs/autocomplete-tokenfield}/index.js +0 -0
- /package/dist/{autocomplete-tokenfield → cjs/autocomplete-tokenfield}/style.scss +0 -0
- /package/dist/{autocomplete-with-suggestions → cjs/autocomplete-with-suggestions}/index.js +0 -0
- /package/dist/{autocomplete-with-suggestions → cjs/autocomplete-with-suggestions}/style.scss +0 -0
- /package/dist/{button → cjs/button}/style.scss +0 -0
- /package/dist/{button-card → cjs/button-card}/index.js +0 -0
- /package/dist/{button-card → cjs/button-card}/style.scss +0 -0
- /package/dist/{card → cjs/card}/index.js +0 -0
- /package/dist/{card → cjs/card}/style.scss +0 -0
- /package/dist/{category-autocomplete → cjs/category-autocomplete}/index.js +0 -0
- /package/dist/{category-autocomplete → cjs/category-autocomplete}/style.scss +0 -0
- /package/dist/{color-picker → cjs/color-picker}/index.js +0 -0
- /package/dist/{color-picker → cjs/color-picker}/style.scss +0 -0
- /package/dist/{consts.js → cjs/consts.js} +0 -0
- /package/dist/{custom-select-control → cjs/custom-select-control}/index.js +0 -0
- /package/dist/{custom-select-control → cjs/custom-select-control}/style.scss +0 -0
- /package/dist/{date-range-picker → cjs/date-range-picker}/index.js +0 -0
- /package/dist/{date-range-picker → cjs/date-range-picker}/style.scss +0 -0
- /package/dist/{footer → cjs/footer}/index.js +0 -0
- /package/dist/{footer → cjs/footer}/style.scss +0 -0
- /package/dist/{form-token-field → cjs/form-token-field}/index.js +0 -0
- /package/dist/{form-token-field → cjs/form-token-field}/style.scss +0 -0
- /package/dist/{global-notices → cjs/global-notices}/index.js +0 -0
- /package/dist/{grid → cjs/grid}/style.scss +0 -0
- /package/dist/{handoff → cjs/handoff}/index.js +0 -0
- /package/dist/{handoff-message → cjs/handoff-message}/index.js +0 -0
- /package/dist/{hooks → cjs/hooks}/useObjectState.js +0 -0
- /package/dist/{hooks → cjs/hooks}/useObjectState.test.js +0 -0
- /package/dist/{hooks → cjs/hooks}/useOnClickOutside.js +0 -0
- /package/dist/{image-upload → cjs/image-upload}/index.js +0 -0
- /package/dist/{image-upload → cjs/image-upload}/index.test.js +0 -0
- /package/dist/{image-upload → cjs/image-upload}/style.scss +0 -0
- /package/dist/{index.js → cjs/index.js} +0 -0
- /package/dist/{info-button → cjs/info-button}/index.js +0 -0
- /package/dist/{info-button → cjs/info-button}/style.scss +0 -0
- /package/dist/{modal → cjs/modal}/index.js +0 -0
- /package/dist/{modal → cjs/modal}/style.scss +0 -0
- /package/dist/{newspack-icon → cjs/newspack-icon}/index.js +0 -0
- /package/dist/{newspack-icon → cjs/newspack-icon}/style.scss +0 -0
- /package/dist/{newspack-logo → cjs/newspack-logo}/index.js +0 -0
- /package/dist/{newspack-logo → cjs/newspack-logo}/style.scss +0 -0
- /package/dist/{notice → cjs/notice}/index.js +0 -0
- /package/dist/{notice → cjs/notice}/style.scss +0 -0
- /package/dist/{patrons-logo → cjs/patrons-logo}/index.js +0 -0
- /package/dist/{plugin-installer → cjs/plugin-installer}/index.js +0 -0
- /package/dist/{plugin-installer → cjs/plugin-installer}/style.scss +0 -0
- /package/dist/{plugin-settings → cjs/plugin-settings}/SettingsSection.js +0 -0
- /package/dist/{plugin-settings → cjs/plugin-settings}/index.js +0 -0
- /package/dist/{plugin-settings → cjs/plugin-settings}/style.scss +0 -0
- /package/dist/{plugin-toggle → cjs/plugin-toggle}/index.js +0 -0
- /package/dist/{plugin-toggle → cjs/plugin-toggle}/style.scss +0 -0
- /package/dist/{popover → cjs/popover}/index.js +0 -0
- /package/dist/{popover → cjs/popover}/style.scss +0 -0
- /package/dist/{position-control → cjs/position-control}/index.js +0 -0
- /package/dist/{position-control → cjs/position-control}/style.scss +0 -0
- /package/dist/{progress-bar → cjs/progress-bar}/index.js +0 -0
- /package/dist/{progress-bar → cjs/progress-bar}/index.test.js +0 -0
- /package/dist/{progress-bar → cjs/progress-bar}/style.scss +0 -0
- /package/dist/{proxied-imports → cjs/proxied-imports}/router.js +0 -0
- /package/dist/{radio-control → cjs/radio-control}/index.js +0 -0
- /package/dist/{radio-control → cjs/radio-control}/style.scss +0 -0
- /package/dist/{section-header → cjs/section-header}/index.js +0 -0
- /package/dist/{section-header → cjs/section-header}/style.scss +0 -0
- /package/dist/{select-control → cjs/select-control}/ButtonGroupControl.js +0 -0
- /package/dist/{select-control → cjs/select-control}/GroupedSelectControl.js +0 -0
- /package/dist/{select-control → cjs/select-control}/index.js +0 -0
- /package/dist/{select-control → cjs/select-control}/style.scss +0 -0
- /package/dist/{settings → cjs/settings}/MinMaxSetting.js +0 -0
- /package/dist/{settings → cjs/settings}/SettingsCard.js +0 -0
- /package/dist/{settings → cjs/settings}/SettingsSection.js +0 -0
- /package/dist/{settings → cjs/settings}/index.js +0 -0
- /package/dist/{settings → cjs/settings}/style.scss +0 -0
- /package/dist/{sortable-newsletter-list-control → cjs/sortable-newsletter-list-control}/index.js +0 -0
- /package/dist/{sortable-newsletter-list-control → cjs/sortable-newsletter-list-control}/style.scss +0 -0
- /package/dist/{steps-list → cjs/steps-list}/index.js +0 -0
- /package/dist/{steps-list → cjs/steps-list}/style.scss +0 -0
- /package/dist/{steps-list-item → cjs/steps-list-item}/index.js +0 -0
- /package/dist/{steps-list-item → cjs/steps-list-item}/style.scss +0 -0
- /package/dist/{style-card → cjs/style-card}/index.js +0 -0
- /package/dist/{style-card → cjs/style-card}/style.scss +0 -0
- /package/dist/{style.scss → cjs/style.scss} +0 -0
- /package/dist/{tabbed-navigation → cjs/tabbed-navigation}/index.js +0 -0
- /package/dist/{tabbed-navigation → cjs/tabbed-navigation}/style.scss +0 -0
- /package/dist/{text-control → cjs/text-control}/style.scss +0 -0
- /package/dist/{utils → cjs/utils}/index.js +0 -0
- /package/dist/{waiting → cjs/waiting}/index.js +0 -0
- /package/dist/{waiting → cjs/waiting}/style.scss +0 -0
- /package/dist/{web-preview → cjs/web-preview}/index.js +0 -0
- /package/dist/{web-preview → cjs/web-preview}/style.scss +0 -0
- /package/dist/{with-wizard → cjs/with-wizard}/index.js +0 -0
- /package/dist/{with-wizard → cjs/with-wizard}/style.scss +0 -0
- /package/dist/{with-wizard-screen → cjs/with-wizard-screen}/index.js +0 -0
- /package/dist/{with-wizard-screen → cjs/with-wizard-screen}/style.scss +0 -0
- /package/dist/{wizard → cjs/wizard}/components/WizardError.js +0 -0
- /package/dist/{wizard → cjs/wizard}/index.js +0 -0
- /package/dist/{wizard → cjs/wizard}/store/index.js +0 -0
- /package/dist/{wizard → cjs/wizard}/store/utils.js +0 -0
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Card
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@use "sass:color";
|
|
6
|
+
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
7
|
+
|
|
8
|
+
.newspack-card.newspack-action-card {
|
|
9
|
+
padding: 0;
|
|
10
|
+
border-color: wp-colors.$gray-300;
|
|
11
|
+
|
|
12
|
+
// Clickable
|
|
13
|
+
|
|
14
|
+
&.newspack-card--is-clickable {
|
|
15
|
+
transition: box-shadow 125ms ease-in-out;
|
|
16
|
+
|
|
17
|
+
&:hover {
|
|
18
|
+
box-shadow: 0 4px 8px rgba(black, 0.08);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Status
|
|
23
|
+
|
|
24
|
+
&.newspack-card__is-disabled,
|
|
25
|
+
&.newspack-card__is-primary,
|
|
26
|
+
&.newspack-card__is-secondary,
|
|
27
|
+
&.newspack-card__is-supported,
|
|
28
|
+
&.newspack-card__is-unsupported {
|
|
29
|
+
box-shadow: inset 4px 0 0 wp-colors.$gray-100;
|
|
30
|
+
|
|
31
|
+
.newspack-action-card__region-top {
|
|
32
|
+
padding-left: 28px;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&.newspack-card__is-primary {
|
|
37
|
+
box-shadow: inset 4px 0 0 var(--wp-admin-theme-color);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&.newspack-card__is-secondary {
|
|
41
|
+
box-shadow: inset 4px 0 0 wp-colors.$alert-yellow;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&.newspack-card__is-supported {
|
|
45
|
+
box-shadow: inset 4px 0 0 wp-colors.$alert-green;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&.newspack-card__is-unsupported {
|
|
49
|
+
box-shadow: inset 4px 0 0 wp-colors.$alert-red;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Small
|
|
53
|
+
&.is-small {
|
|
54
|
+
.newspack-action-card__region-top {
|
|
55
|
+
padding: 8px 16px;
|
|
56
|
+
|
|
57
|
+
.components-toggle-control {
|
|
58
|
+
margin-bottom: 16px;
|
|
59
|
+
|
|
60
|
+
@media screen and ( min-width: 744px ) {
|
|
61
|
+
margin-bottom: 0;
|
|
62
|
+
margin-right: 16px;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
h2 {
|
|
68
|
+
font-size: 14px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
p,
|
|
72
|
+
.newspack-action-card__region-right,
|
|
73
|
+
.newspack-action-card__primary_button {
|
|
74
|
+
font-size: 12px;
|
|
75
|
+
line-height: 16px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
code {
|
|
79
|
+
padding: 0 4px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
& + & {
|
|
83
|
+
margin-top: -16px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&.mv0 {
|
|
87
|
+
border-left-color: wp-colors.$gray-300;
|
|
88
|
+
border-radius: 0;
|
|
89
|
+
border-right-color: wp-colors.$gray-300;
|
|
90
|
+
|
|
91
|
+
&:first-of-type {
|
|
92
|
+
border-top-color: wp-colors.$gray-300;
|
|
93
|
+
border-top-left-radius: 3px;
|
|
94
|
+
border-top-right-radius: 3px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&:last-of-type {
|
|
98
|
+
border-bottom-color: wp-colors.$gray-300;
|
|
99
|
+
border-bottom-left-radius: 3px;
|
|
100
|
+
border-bottom-right-radius: 3px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
& + & {
|
|
104
|
+
margin-top: -1px;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&.newspack-card__is-disabled,
|
|
109
|
+
&.newspack-card__is-primary,
|
|
110
|
+
&.newspack-card__is-secondary,
|
|
111
|
+
&.newspack-card__is-supported,
|
|
112
|
+
&.newspack-card__is-unsupported {
|
|
113
|
+
.newspack-action-card__region-top {
|
|
114
|
+
padding-left: 20px;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Medium
|
|
120
|
+
|
|
121
|
+
&.is-medium {
|
|
122
|
+
.newspack-action-card__region-top {
|
|
123
|
+
padding: 16px;
|
|
124
|
+
|
|
125
|
+
.components-toggle-control {
|
|
126
|
+
margin-bottom: 16px;
|
|
127
|
+
|
|
128
|
+
@media screen and ( min-width: 744px ) {
|
|
129
|
+
margin-bottom: 0;
|
|
130
|
+
margin-right: 16px;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.newspack-action-card__region-left {
|
|
136
|
+
margin-bottom: 16px;
|
|
137
|
+
|
|
138
|
+
@media screen and ( min-width: 744px ) {
|
|
139
|
+
margin-bottom: 0;
|
|
140
|
+
margin-right: 16px;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.newspack-action-card__region-children {
|
|
145
|
+
padding: 0 32px 32px;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Nested children
|
|
150
|
+
|
|
151
|
+
&.newspack-card--has-children {
|
|
152
|
+
.newspack-action-card {
|
|
153
|
+
&:first-child {
|
|
154
|
+
margin-top: 32px;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
+ .newspack-action-card {
|
|
158
|
+
margin-top: 16px !important;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&:last-child {
|
|
162
|
+
margin-bottom: 0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Has grey header
|
|
168
|
+
|
|
169
|
+
&.newspack-card--has-grey-header {
|
|
170
|
+
overflow: hidden;
|
|
171
|
+
|
|
172
|
+
&.newspack-card--has-children {
|
|
173
|
+
.newspack-action-card__region-top {
|
|
174
|
+
border-bottom: 1px solid wp-colors.$gray-300;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.is-small > .newspack-action-card__region-top {
|
|
178
|
+
padding-bottom: 8px;
|
|
179
|
+
padding-top: 8px;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.newspack-action-card__region-top {
|
|
184
|
+
background-color: rgba(black, 0.025);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.newspack-action-card__region-center {
|
|
188
|
+
p {
|
|
189
|
+
color: color.adjust(wp-colors.$gray-700, $lightness: -0.75%);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
&.newspack-card--has-white-header {
|
|
195
|
+
.newspack-action-card__region-top {
|
|
196
|
+
background-color: transparent;
|
|
197
|
+
border: none !important;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Indent
|
|
202
|
+
|
|
203
|
+
&.newspack-card--indent {
|
|
204
|
+
margin-left: 56px;
|
|
205
|
+
position: relative;
|
|
206
|
+
|
|
207
|
+
&::before {
|
|
208
|
+
border: 0 solid wp-colors.$gray-300;
|
|
209
|
+
border-left-width: 1px;
|
|
210
|
+
border-bottom-width: 1px;
|
|
211
|
+
border-radius: 0 0 0 2px;
|
|
212
|
+
content: "";
|
|
213
|
+
display: block;
|
|
214
|
+
position: absolute;
|
|
215
|
+
inset: -17px 100% 50% -28px;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Typography
|
|
220
|
+
|
|
221
|
+
h2,
|
|
222
|
+
p:not([class*="components-base-control"]) {
|
|
223
|
+
margin: 0;
|
|
224
|
+
max-width: 100%;
|
|
225
|
+
width: 100%;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
h2 {
|
|
229
|
+
align-items: center;
|
|
230
|
+
display: flex;
|
|
231
|
+
flex-wrap: wrap;
|
|
232
|
+
margin-right: -8px;
|
|
233
|
+
|
|
234
|
+
.newspack-action-card__title {
|
|
235
|
+
margin-right: 8px;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
a {
|
|
239
|
+
color: inherit;
|
|
240
|
+
text-decoration: none;
|
|
241
|
+
|
|
242
|
+
&:active,
|
|
243
|
+
&:focus,
|
|
244
|
+
&:hover {
|
|
245
|
+
color: var(--wp-admin-theme-color);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Regions
|
|
251
|
+
|
|
252
|
+
.newspack-action-card__region {
|
|
253
|
+
align-items: center;
|
|
254
|
+
display: flex;
|
|
255
|
+
justify-content: space-between;
|
|
256
|
+
margin: 0;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.newspack-action-card__region-top {
|
|
260
|
+
padding: 24px;
|
|
261
|
+
display: block;
|
|
262
|
+
|
|
263
|
+
@media screen and ( min-width: 744px ) {
|
|
264
|
+
display: flex;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Toggle Control
|
|
268
|
+
.components-toggle-control {
|
|
269
|
+
margin-bottom: 24px;
|
|
270
|
+
margin-top: 0;
|
|
271
|
+
|
|
272
|
+
@media screen and ( min-width: 744px ) {
|
|
273
|
+
margin-bottom: 0;
|
|
274
|
+
margin-right: 24px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.components-base-control__field {
|
|
278
|
+
margin-bottom: 0;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.components-form-toggle {
|
|
282
|
+
display: flex;
|
|
283
|
+
margin: 0;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.newspack-action-card__region-children {
|
|
289
|
+
padding: 0 24px 24px;
|
|
290
|
+
|
|
291
|
+
&__inner {
|
|
292
|
+
padding-top: 32px;
|
|
293
|
+
|
|
294
|
+
> *:first-child {
|
|
295
|
+
margin-top: 0 !important;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
> *:last-child {
|
|
299
|
+
margin-bottom: 0 !important;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.newspack-section-header {
|
|
304
|
+
margin: 32px 0 16px;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.newspack-card,
|
|
308
|
+
.newspack-checkbox-control,
|
|
309
|
+
.newspack-grid,
|
|
310
|
+
.newspack-text-control,
|
|
311
|
+
.newspack-toggle-control {
|
|
312
|
+
margin: 16px 0;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.newspack-action-card__region-left {
|
|
317
|
+
margin-bottom: 24px;
|
|
318
|
+
|
|
319
|
+
@media screen and ( min-width: 744px ) {
|
|
320
|
+
margin-bottom: 0;
|
|
321
|
+
margin-right: 24px;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.newspack-action-card__region-center {
|
|
326
|
+
align-items: flex-start;
|
|
327
|
+
flex: 1 1 auto;
|
|
328
|
+
flex-wrap: wrap;
|
|
329
|
+
|
|
330
|
+
.newspack-grid {
|
|
331
|
+
width: 100%;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
p {
|
|
335
|
+
color: wp-colors.$gray-700;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.newspack-action-card__region-right {
|
|
340
|
+
align-items: flex-start;
|
|
341
|
+
flex: 0 0 auto;
|
|
342
|
+
flex-direction: column;
|
|
343
|
+
margin-top: 24px;
|
|
344
|
+
text-align: right;
|
|
345
|
+
|
|
346
|
+
@media screen and ( min-width: 744px ) {
|
|
347
|
+
align-items: flex-end;
|
|
348
|
+
flex-direction: column;
|
|
349
|
+
margin-left: 24px;
|
|
350
|
+
margin-top: 0;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
> * {
|
|
354
|
+
text-align: inherit;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.newspack-action-card__secondary_button {
|
|
358
|
+
margin-top: 8px;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Waiting
|
|
363
|
+
|
|
364
|
+
.newspack-action-card__container {
|
|
365
|
+
display: flex;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// Notifications
|
|
369
|
+
|
|
370
|
+
.newspack-action-card__notification {
|
|
371
|
+
.newspack-notice {
|
|
372
|
+
margin: 0;
|
|
373
|
+
|
|
374
|
+
&__heading {
|
|
375
|
+
margin-top: 0;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
&.newspack-action-card__region-children {
|
|
380
|
+
.newspack-notice {
|
|
381
|
+
margin-top: 32px;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// Image
|
|
387
|
+
|
|
388
|
+
.newspack-action-card__image {
|
|
389
|
+
background-position: center;
|
|
390
|
+
background-repeat: no-repeat;
|
|
391
|
+
background-size: cover;
|
|
392
|
+
border-radius: 50%;
|
|
393
|
+
height: 48px;
|
|
394
|
+
width: 48px;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Icon
|
|
398
|
+
|
|
399
|
+
.newspack_plugin-installer__icon {
|
|
400
|
+
margin: 0;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// Badge
|
|
404
|
+
|
|
405
|
+
.newspack-action-card__badge {
|
|
406
|
+
background: wp-colors.$gray-100;
|
|
407
|
+
border-radius: 2px;
|
|
408
|
+
color: wp-colors.$gray-900;
|
|
409
|
+
display: block;
|
|
410
|
+
flex: 0 0 auto;
|
|
411
|
+
font-size: 10px;
|
|
412
|
+
font-weight: bold;
|
|
413
|
+
line-height: 1.4;
|
|
414
|
+
margin: 0 8px 0 0;
|
|
415
|
+
padding: 2px 8px;
|
|
416
|
+
text-transform: uppercase;
|
|
417
|
+
|
|
418
|
+
+ .newspack-action-card__badge {
|
|
419
|
+
margin-left: -4px;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// Description Card
|
|
424
|
+
|
|
425
|
+
&.newspack-description-card {
|
|
426
|
+
font-style: italic;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Expandable card children
|
|
430
|
+
|
|
431
|
+
&.is-expandable {
|
|
432
|
+
.newspack-action-card__title .components-button.is-link {
|
|
433
|
+
color: inherit;
|
|
434
|
+
font-size: inherit;
|
|
435
|
+
font-weight: inherit;
|
|
436
|
+
text-decoration: inherit;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.newspack-action-card__region-children {
|
|
440
|
+
border-top: 1px solid wp-colors.$gray-100;
|
|
441
|
+
padding-top: 24px;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
&.is-medium .newspack-action-card__region-children {
|
|
445
|
+
padding-top: 32px;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
&.has-checkbox {
|
|
449
|
+
.newspack-action-card__region-children {
|
|
450
|
+
padding-left: 72px;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
&.is-small .newspack-action-card__region-children {
|
|
454
|
+
padding-left: 64px;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
&.is-medium .newspack-action-card__region-children {
|
|
458
|
+
padding-left: 56px;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// Action content with multiple buttons
|
|
464
|
+
&.has-action-content .newspack-action-card__region-right {
|
|
465
|
+
flex-direction: row;
|
|
466
|
+
|
|
467
|
+
.components-button + .components-button {
|
|
468
|
+
margin-left: 8px;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// Multiple Cards
|
|
473
|
+
|
|
474
|
+
& + & {
|
|
475
|
+
margin-top: -16px;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
.newspack-card {
|
|
480
|
+
.newspack-card.newspack-action-card {
|
|
481
|
+
border: 1px solid wp-colors.$gray-200;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import debounce from 'lodash/debounce';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Component } from '@wordpress/element';
|
|
10
|
+
import { FormTokenField, Spinner } from '@wordpress/components';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import './style.scss';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* An multi-selecting, api-driven autocomplete input suitable for use in block attributes.
|
|
19
|
+
*/
|
|
20
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
class AutocompleteTokenField extends Component {
|
|
22
|
+
constructor(props) {
|
|
23
|
+
super(props);
|
|
24
|
+
this.state = {
|
|
25
|
+
suggestions: [],
|
|
26
|
+
validValues: {},
|
|
27
|
+
loading: this.isFetchingInfoOnLoad()
|
|
28
|
+
};
|
|
29
|
+
this.debouncedUpdateSuggestions = debounce(this.updateSuggestions, 500);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* If the component has tokens passed in props, it should fetch info after it mounts.
|
|
34
|
+
*/
|
|
35
|
+
isFetchingInfoOnLoad = () => {
|
|
36
|
+
const {
|
|
37
|
+
tokens,
|
|
38
|
+
fetchSavedInfo
|
|
39
|
+
} = this.props;
|
|
40
|
+
return Boolean(tokens.length && fetchSavedInfo);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* When the component loads, fetch information about the tokens so we can populate
|
|
45
|
+
* the tokens with the correct labels.
|
|
46
|
+
*/
|
|
47
|
+
componentDidMount() {
|
|
48
|
+
if (this.isFetchingInfoOnLoad()) {
|
|
49
|
+
const {
|
|
50
|
+
tokens,
|
|
51
|
+
fetchSavedInfo
|
|
52
|
+
} = this.props;
|
|
53
|
+
fetchSavedInfo(tokens).then(results => {
|
|
54
|
+
const {
|
|
55
|
+
validValues
|
|
56
|
+
} = this.state;
|
|
57
|
+
results.forEach(suggestion => {
|
|
58
|
+
validValues[suggestion.value] = suggestion.label;
|
|
59
|
+
});
|
|
60
|
+
this.setState({
|
|
61
|
+
validValues,
|
|
62
|
+
loading: false
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* When the component updates, fetch information about the tokens so we can populate
|
|
70
|
+
* the tokens with the correct labels.
|
|
71
|
+
*/
|
|
72
|
+
componentDidUpdate(prevProps) {
|
|
73
|
+
const {
|
|
74
|
+
tokens,
|
|
75
|
+
fetchSavedInfo
|
|
76
|
+
} = this.props;
|
|
77
|
+
if (tokens !== prevProps.tokens && this.isFetchingInfoOnLoad()) {
|
|
78
|
+
fetchSavedInfo(tokens).then(results => {
|
|
79
|
+
const {
|
|
80
|
+
validValues
|
|
81
|
+
} = this.state;
|
|
82
|
+
results.forEach(suggestion => {
|
|
83
|
+
validValues[suggestion.value] = suggestion.label;
|
|
84
|
+
});
|
|
85
|
+
this.setState({
|
|
86
|
+
validValues,
|
|
87
|
+
loading: false
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Clean up any unfinished autocomplete api call requests.
|
|
95
|
+
*/
|
|
96
|
+
componentWillUnmount() {
|
|
97
|
+
delete this.suggestionsRequest;
|
|
98
|
+
this.debouncedUpdateSuggestions.cancel();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get a list of labels for input values.
|
|
103
|
+
*
|
|
104
|
+
* @param {Array} values Array of values (ids, etc.).
|
|
105
|
+
* @return {Array} array of valid labels corresponding to the values.
|
|
106
|
+
*/
|
|
107
|
+
getLabelsForValues(values) {
|
|
108
|
+
const {
|
|
109
|
+
validValues
|
|
110
|
+
} = this.state;
|
|
111
|
+
return values.reduce((accumulator, value) => {
|
|
112
|
+
if (!value) {
|
|
113
|
+
return accumulator;
|
|
114
|
+
}
|
|
115
|
+
if (value.label) {
|
|
116
|
+
return [...accumulator, value.label];
|
|
117
|
+
}
|
|
118
|
+
return validValues[value] ? [...accumulator, validValues[value]] : accumulator;
|
|
119
|
+
}, []);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get a list of values for input labels.
|
|
124
|
+
*
|
|
125
|
+
* @param {Array} labels Array of labels from the tokens.
|
|
126
|
+
* @return {Array} Array of valid values corresponding to the labels.
|
|
127
|
+
*/
|
|
128
|
+
getValuesForLabels(labels) {
|
|
129
|
+
const {
|
|
130
|
+
returnFullObjects
|
|
131
|
+
} = this.props; // If this prop is passed, return both the value and label. Otherwise, return just the label.
|
|
132
|
+
const {
|
|
133
|
+
validValues
|
|
134
|
+
} = this.state;
|
|
135
|
+
if (returnFullObjects) {
|
|
136
|
+
return labels.reduce((acc, label) => {
|
|
137
|
+
Object.keys(validValues).forEach(key => {
|
|
138
|
+
if (validValues[key] === label) {
|
|
139
|
+
// Preserve numeric or string type of values. Object.keys will convert numbers to strings.
|
|
140
|
+
const value = isNaN(parseInt(key)) ? key.toString() : parseInt(key);
|
|
141
|
+
acc.push({
|
|
142
|
+
value,
|
|
143
|
+
label
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return acc;
|
|
148
|
+
}, []);
|
|
149
|
+
}
|
|
150
|
+
return labels.map(label => Object.keys(validValues).map(key => isNaN(parseInt(key)) ? key.toString() : parseInt(key)).find(key => validValues[key] === label));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Refresh the autocomplete dropdown.
|
|
155
|
+
*
|
|
156
|
+
* @param {string} input Input to fetch suggestions for
|
|
157
|
+
*/
|
|
158
|
+
updateSuggestions(input) {
|
|
159
|
+
const {
|
|
160
|
+
fetchSuggestions
|
|
161
|
+
} = this.props;
|
|
162
|
+
if (!fetchSuggestions) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
this.setState({
|
|
166
|
+
loading: true
|
|
167
|
+
}, () => {
|
|
168
|
+
const request = fetchSuggestions(input);
|
|
169
|
+
request.then(suggestions => {
|
|
170
|
+
// A fetch Promise doesn't have an abort option. It's mimicked by
|
|
171
|
+
// comparing the request reference in on the instance, which is
|
|
172
|
+
// reset or deleted on subsequent requests or unmounting.
|
|
173
|
+
if (this.suggestionsRequest !== request) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const {
|
|
177
|
+
validValues
|
|
178
|
+
} = this.state;
|
|
179
|
+
const currentSuggestions = [...suggestions];
|
|
180
|
+
suggestions.forEach(suggestion => {
|
|
181
|
+
validValues[suggestion.value] = suggestion.label;
|
|
182
|
+
});
|
|
183
|
+
this.setState({
|
|
184
|
+
suggestions: currentSuggestions,
|
|
185
|
+
validValues,
|
|
186
|
+
loading: false
|
|
187
|
+
});
|
|
188
|
+
}).catch(() => {
|
|
189
|
+
if (this.suggestionsRequest === request) {
|
|
190
|
+
this.setState({
|
|
191
|
+
loading: false
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
this.suggestionsRequest = request;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* When a token is selected, we need to convert the string label into a recognized value suitable for saving as an attribute.
|
|
201
|
+
*
|
|
202
|
+
* @param {Array} tokenStrings An array of token label strings.
|
|
203
|
+
*/
|
|
204
|
+
handleOnChange(tokenStrings) {
|
|
205
|
+
const {
|
|
206
|
+
onChange
|
|
207
|
+
} = this.props;
|
|
208
|
+
onChange(this.getValuesForLabels(tokenStrings));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* To populate the tokens, we need to convert the values into a human-readable label.
|
|
213
|
+
*
|
|
214
|
+
* @return {Array} An array of token label strings.
|
|
215
|
+
*/
|
|
216
|
+
getTokens() {
|
|
217
|
+
const {
|
|
218
|
+
tokens
|
|
219
|
+
} = this.props;
|
|
220
|
+
return this.getLabelsForValues(tokens);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Render.
|
|
225
|
+
*/
|
|
226
|
+
render() {
|
|
227
|
+
const {
|
|
228
|
+
help,
|
|
229
|
+
label = '',
|
|
230
|
+
placeholder = '',
|
|
231
|
+
maxLength
|
|
232
|
+
} = this.props;
|
|
233
|
+
const {
|
|
234
|
+
suggestions,
|
|
235
|
+
loading
|
|
236
|
+
} = this.state;
|
|
237
|
+
const classNames = ['newspack-autocomplete-tokenfield__input-container'];
|
|
238
|
+
if (label) {
|
|
239
|
+
classNames.push('has-label');
|
|
240
|
+
}
|
|
241
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
242
|
+
className: "newspack-autocomplete-tokenfield",
|
|
243
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
244
|
+
className: classNames.join(' '),
|
|
245
|
+
children: [/*#__PURE__*/_jsx(FormTokenField, {
|
|
246
|
+
value: this.getTokens(),
|
|
247
|
+
suggestions: suggestions.map(suggestion => suggestion.label),
|
|
248
|
+
onChange: tokens => this.handleOnChange(tokens),
|
|
249
|
+
onInputChange: input => this.debouncedUpdateSuggestions(input),
|
|
250
|
+
label: label,
|
|
251
|
+
maxLength: maxLength,
|
|
252
|
+
placeholder: placeholder
|
|
253
|
+
}), loading && /*#__PURE__*/_jsx(Spinner, {})]
|
|
254
|
+
}), help && /*#__PURE__*/_jsx("p", {
|
|
255
|
+
className: "newspack-autocomplete-tokenfield__help",
|
|
256
|
+
children: help
|
|
257
|
+
})]
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
export default AutocompleteTokenField;
|