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,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button Card
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
6
|
+
|
|
7
|
+
.newspack-button-card {
|
|
8
|
+
background: white;
|
|
9
|
+
border-radius: 2px;
|
|
10
|
+
border: 1px solid wp-colors.$gray-300;
|
|
11
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) transparent;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
display: block;
|
|
14
|
+
margin: 32px 0;
|
|
15
|
+
padding: 32px;
|
|
16
|
+
position: relative;
|
|
17
|
+
text-decoration: none;
|
|
18
|
+
transition:
|
|
19
|
+
background-color 125ms ease-in-out,
|
|
20
|
+
border-color 125ms ease-in-out,
|
|
21
|
+
box-shadow 125ms ease-in-out;
|
|
22
|
+
|
|
23
|
+
&:focus,
|
|
24
|
+
&.is-pressed {
|
|
25
|
+
background: white;
|
|
26
|
+
border-color: var(--wp-admin-theme-color);
|
|
27
|
+
box-shadow: inset 0 0 0 1px var(--wp-admin-theme-color) !important;
|
|
28
|
+
outline: none !important;
|
|
29
|
+
z-index: 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&.is-pressed:focus-visible {
|
|
33
|
+
box-shadow:
|
|
34
|
+
inset 0 0 0 1px var(--wp-admin-theme-color),
|
|
35
|
+
0 0 0 1px white,
|
|
36
|
+
0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color) !important;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&:active,
|
|
40
|
+
&:hover {
|
|
41
|
+
border-color: var(--wp-admin-theme-color);
|
|
42
|
+
color: var(--wp-admin-theme-color);
|
|
43
|
+
text-decoration: none;
|
|
44
|
+
z-index: 1;
|
|
45
|
+
|
|
46
|
+
.newspack-grid h3,
|
|
47
|
+
p {
|
|
48
|
+
color: inherit;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.newspack-grid h3,
|
|
53
|
+
p {
|
|
54
|
+
transition: color 125ms ease-in-out;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.newspack-grid h3 {
|
|
58
|
+
color: wp-colors.$gray-900;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
p {
|
|
62
|
+
color: wp-colors.$gray-700;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Grouped
|
|
66
|
+
|
|
67
|
+
&.grouped {
|
|
68
|
+
border-radius: 0;
|
|
69
|
+
|
|
70
|
+
& + &:not(.br--top) {
|
|
71
|
+
margin-top: -33px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&.br--bottom {
|
|
75
|
+
border-bottom-left-radius: 2px;
|
|
76
|
+
border-bottom-right-radius: 2px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&.br--top {
|
|
80
|
+
border-top-left-radius: 2px;
|
|
81
|
+
border-top-right-radius: 2px;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Chevron & Icon
|
|
86
|
+
|
|
87
|
+
&.has-chevron,
|
|
88
|
+
&.has-icon {
|
|
89
|
+
align-items: center;
|
|
90
|
+
display: grid;
|
|
91
|
+
grid-gap: 16px;
|
|
92
|
+
grid-template-columns: auto 24px;
|
|
93
|
+
|
|
94
|
+
&:active,
|
|
95
|
+
&:hover {
|
|
96
|
+
svg {
|
|
97
|
+
fill: currentcolor;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
svg {
|
|
102
|
+
fill: var(--wp-admin-theme-color);
|
|
103
|
+
transition: fill 125ms ease-in-out;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&.has-icon {
|
|
108
|
+
grid-template-columns: 48px auto;
|
|
109
|
+
|
|
110
|
+
&.has-chevron {
|
|
111
|
+
grid-template-columns: 48px auto 24px;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Is Small
|
|
116
|
+
|
|
117
|
+
&.is-small {
|
|
118
|
+
padding: 16px;
|
|
119
|
+
|
|
120
|
+
&.has-chevron,
|
|
121
|
+
&.has-icon {
|
|
122
|
+
svg {
|
|
123
|
+
height: 24px;
|
|
124
|
+
width: 24px;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&.has-icon {
|
|
129
|
+
grid-template-columns: 24px auto;
|
|
130
|
+
|
|
131
|
+
&.has-chevron {
|
|
132
|
+
grid-template-columns: 24px auto 24px;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
h3 {
|
|
137
|
+
font-size: 1em;
|
|
138
|
+
line-height: 1.5;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
p {
|
|
142
|
+
font-size: 12px;
|
|
143
|
+
line-height: 1.4;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Is Destructive
|
|
148
|
+
|
|
149
|
+
&.is-destructive {
|
|
150
|
+
.title {
|
|
151
|
+
color: wp-colors.$alert-red;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&.has-chevron,
|
|
155
|
+
&.has-icon {
|
|
156
|
+
svg {
|
|
157
|
+
fill: wp-colors.$alert-red;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&:focus,
|
|
162
|
+
&.is-pressed {
|
|
163
|
+
border-color: wp-colors.$alert-red;
|
|
164
|
+
box-shadow: inset 0 0 0 1px wp-colors.$alert-red !important;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&.is-pressed:focus-visible {
|
|
168
|
+
box-shadow:
|
|
169
|
+
inset 0 0 0 1px wp-colors.$alert-red,
|
|
170
|
+
0 0 0 1px white,
|
|
171
|
+
0 0 0 var(--wp-admin-border-width-focus) wp-colors.$alert-red !important;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
&:active,
|
|
175
|
+
&:hover {
|
|
176
|
+
background-color: wp-colors.$gray-100;
|
|
177
|
+
border-color: wp-colors.$alert-red;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Card
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* WordPress dependencies
|
|
7
|
+
*/
|
|
8
|
+
import { Component } from '@wordpress/element';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import './style.scss';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* External dependencies
|
|
17
|
+
*/
|
|
18
|
+
import classNames from 'classnames';
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
+
class Card extends Component {
|
|
21
|
+
/**
|
|
22
|
+
* Render
|
|
23
|
+
*/
|
|
24
|
+
render() {
|
|
25
|
+
const {
|
|
26
|
+
buttonsCard,
|
|
27
|
+
className,
|
|
28
|
+
headerActions,
|
|
29
|
+
isNarrow,
|
|
30
|
+
isMedium,
|
|
31
|
+
isSmall,
|
|
32
|
+
isWhite,
|
|
33
|
+
noBorder,
|
|
34
|
+
...otherProps
|
|
35
|
+
} = this.props;
|
|
36
|
+
const classes = classNames('newspack-card', className, buttonsCard && 'newspack-card__buttons-card', headerActions && 'newspack-card__header-actions', isMedium && 'newspack-card__is-medium', isNarrow && 'newspack-card__is-narrow', isSmall && 'newspack-card__is-small', isWhite && 'newspack-card__is-white', noBorder && 'newspack-card__no-border');
|
|
37
|
+
return /*#__PURE__*/_jsx("div", {
|
|
38
|
+
className: classes,
|
|
39
|
+
...otherProps
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export default Card;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Card
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@use "~@wordpress/base-styles/colors" as wp-colors;
|
|
6
|
+
|
|
7
|
+
.newspack-card {
|
|
8
|
+
border-radius: 2px;
|
|
9
|
+
border: 1px solid wp-colors.$gray-300;
|
|
10
|
+
color: wp-colors.$gray-900;
|
|
11
|
+
margin: 32px 0;
|
|
12
|
+
padding: 16px 48px;
|
|
13
|
+
|
|
14
|
+
@media screen and ( min-width: 744px ) {
|
|
15
|
+
padding: 32px 64px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Buttons Card
|
|
19
|
+
|
|
20
|
+
&__buttons-card {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-wrap: wrap;
|
|
23
|
+
gap: 16px;
|
|
24
|
+
margin: 32px 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Header Actions Card
|
|
28
|
+
|
|
29
|
+
&__header-actions {
|
|
30
|
+
align-items: center;
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
gap: 8px;
|
|
34
|
+
justify-content: space-between;
|
|
35
|
+
margin-bottom: -16px;
|
|
36
|
+
|
|
37
|
+
> * {
|
|
38
|
+
margin-bottom: 0 !important;
|
|
39
|
+
margin-top: 0 !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.newspack-select-control {
|
|
43
|
+
.components-base-control__field {
|
|
44
|
+
margin-bottom: 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Is Narrow
|
|
50
|
+
|
|
51
|
+
&__is-narrow {
|
|
52
|
+
margin-left: auto;
|
|
53
|
+
margin-right: auto;
|
|
54
|
+
|
|
55
|
+
@media screen and ( min-width: 608px ) {
|
|
56
|
+
max-width: 576px;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Is Small
|
|
61
|
+
|
|
62
|
+
&__is-small {
|
|
63
|
+
padding: 16px;
|
|
64
|
+
|
|
65
|
+
> *:first-child {
|
|
66
|
+
margin-top: 0 !important;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
> *:last-child {
|
|
70
|
+
margin-bottom: 0 !important;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
> p {
|
|
74
|
+
margin: 16px 0 !important;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
& + & {
|
|
78
|
+
margin-top: -16px;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Is Medium
|
|
83
|
+
|
|
84
|
+
&__is-medium {
|
|
85
|
+
padding: 32px;
|
|
86
|
+
|
|
87
|
+
> *:first-child {
|
|
88
|
+
margin-top: 0 !important;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
> *:last-child {
|
|
92
|
+
margin-bottom: 0 !important;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Is White
|
|
97
|
+
|
|
98
|
+
&__is-white {
|
|
99
|
+
background: white;
|
|
100
|
+
border: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// No Border
|
|
104
|
+
|
|
105
|
+
&__no-border {
|
|
106
|
+
border-radius: 0;
|
|
107
|
+
border: 0;
|
|
108
|
+
padding: 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Margin
|
|
112
|
+
|
|
113
|
+
&.mt64 {
|
|
114
|
+
margin-top: 64px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&.mt16 {
|
|
118
|
+
margin-top: 16px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Typography
|
|
122
|
+
|
|
123
|
+
small {
|
|
124
|
+
font-size: 12px;
|
|
125
|
+
line-height: 1.4;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
code {
|
|
129
|
+
background: wp-colors.$gray-100;
|
|
130
|
+
color: wp-colors.$gray-900;
|
|
131
|
+
padding: 0 0.5em;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Thematic Break
|
|
135
|
+
|
|
136
|
+
hr {
|
|
137
|
+
background: wp-colors.$gray-300;
|
|
138
|
+
border: 0;
|
|
139
|
+
height: 1px;
|
|
140
|
+
margin: 48px 0;
|
|
141
|
+
|
|
142
|
+
@media screen and ( min-width: 744px ) {
|
|
143
|
+
margin: 64px 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Separator
|
|
148
|
+
|
|
149
|
+
.sep {
|
|
150
|
+
background: wp-colors.$gray-300;
|
|
151
|
+
height: 1px;
|
|
152
|
+
margin-left: 8px;
|
|
153
|
+
margin-right: 8px;
|
|
154
|
+
width: 12px;
|
|
155
|
+
|
|
156
|
+
&__inline {
|
|
157
|
+
display: inline-block;
|
|
158
|
+
line-height: 1.5;
|
|
159
|
+
vertical-align: middle;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Error
|
|
164
|
+
|
|
165
|
+
.newspack-error {
|
|
166
|
+
color: wp-colors.$alert-red;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Category Autocomplete
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* WordPress dependencies.
|
|
7
|
+
*/
|
|
8
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
9
|
+
import { Spinner } from '@wordpress/components';
|
|
10
|
+
import { Component } from '@wordpress/element';
|
|
11
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies.
|
|
15
|
+
*/
|
|
16
|
+
import { FormTokenField } from '../';
|
|
17
|
+
import './style.scss';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* External dependencies
|
|
21
|
+
*/
|
|
22
|
+
import debounce from 'lodash/debounce';
|
|
23
|
+
import find from 'lodash/find';
|
|
24
|
+
import filter from 'lodash/filter';
|
|
25
|
+
import classnames from 'classnames';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Category autocomplete field component.
|
|
29
|
+
*/
|
|
30
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
31
|
+
class CategoryAutocomplete extends Component {
|
|
32
|
+
state = {
|
|
33
|
+
suggestions: {},
|
|
34
|
+
allCategories: {},
|
|
35
|
+
isLoading: false
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Class constructor.
|
|
40
|
+
*/
|
|
41
|
+
constructor(props) {
|
|
42
|
+
super(props);
|
|
43
|
+
this.debouncedUpdateSuggestions = debounce(this.updateSuggestions, 100);
|
|
44
|
+
}
|
|
45
|
+
componentDidMount() {
|
|
46
|
+
this.setState({
|
|
47
|
+
isLoading: true
|
|
48
|
+
});
|
|
49
|
+
apiFetch({
|
|
50
|
+
path: addQueryArgs(`/wp/v2/${this.props.taxonomy}`, {
|
|
51
|
+
per_page: -1,
|
|
52
|
+
_fields: 'id,name'
|
|
53
|
+
})
|
|
54
|
+
}).then(categories => this.setState({
|
|
55
|
+
allCategories: categories
|
|
56
|
+
})).finally(() => this.setState({
|
|
57
|
+
isLoading: false
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Clean up debounced suggestions method.
|
|
63
|
+
*/
|
|
64
|
+
componentWillUnmount() {
|
|
65
|
+
this.debouncedUpdateSuggestions.cancel();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Refresh the autocomplete UI based on text that was typed.
|
|
70
|
+
*
|
|
71
|
+
* @param {string} search The typed text to search for.
|
|
72
|
+
*/
|
|
73
|
+
updateSuggestions(search) {
|
|
74
|
+
this.setState({
|
|
75
|
+
isLoading: true
|
|
76
|
+
});
|
|
77
|
+
apiFetch({
|
|
78
|
+
path: addQueryArgs(`/wp/v2/${this.props.taxonomy}`, {
|
|
79
|
+
search,
|
|
80
|
+
per_page: 20,
|
|
81
|
+
_fields: 'id,name',
|
|
82
|
+
orderby: 'count',
|
|
83
|
+
order: 'desc'
|
|
84
|
+
})
|
|
85
|
+
}).then(categories => {
|
|
86
|
+
this.setState({
|
|
87
|
+
suggestions: categories.reduce((accumulator, category) => ({
|
|
88
|
+
...accumulator,
|
|
89
|
+
[category.name]: category
|
|
90
|
+
}), {})
|
|
91
|
+
});
|
|
92
|
+
}).finally(() => this.setState({
|
|
93
|
+
isLoading: false
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Prepare categories data for the API endpoint, call the change handler.
|
|
99
|
+
*
|
|
100
|
+
* @param {Array} tokens An array of category tokens.
|
|
101
|
+
*/
|
|
102
|
+
handleOnChange = tokens => {
|
|
103
|
+
const {
|
|
104
|
+
onChange
|
|
105
|
+
} = this.props;
|
|
106
|
+
const {
|
|
107
|
+
suggestions
|
|
108
|
+
} = this.state;
|
|
109
|
+
// Categories that are already will be objects, while new additions will be strings (the name).
|
|
110
|
+
// allValues nomalizes the array so that they are all objects.
|
|
111
|
+
const allValues = tokens.filter(token => 'undefined' !== typeof token) // Ensure each token is a valid value.
|
|
112
|
+
.map(token => 'string' === typeof token ? suggestions[token] : token).filter(Boolean);
|
|
113
|
+
onChange(allValues);
|
|
114
|
+
};
|
|
115
|
+
getAvailableSuggestions = () => {
|
|
116
|
+
const {
|
|
117
|
+
value
|
|
118
|
+
} = this.props;
|
|
119
|
+
const {
|
|
120
|
+
suggestions
|
|
121
|
+
} = this.state;
|
|
122
|
+
const selectedIds = value.reduce((acc, item) => {
|
|
123
|
+
if (item?.id) {
|
|
124
|
+
acc.push(item.id);
|
|
125
|
+
}
|
|
126
|
+
return acc;
|
|
127
|
+
}, []);
|
|
128
|
+
const availableSuggestions = filter(suggestions, ({
|
|
129
|
+
id
|
|
130
|
+
}) => selectedIds.indexOf(id) === -1);
|
|
131
|
+
return availableSuggestions.map(v => v.name);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Render the component.
|
|
136
|
+
*/
|
|
137
|
+
render() {
|
|
138
|
+
const {
|
|
139
|
+
className,
|
|
140
|
+
disabled,
|
|
141
|
+
description,
|
|
142
|
+
hideHelpFromVision,
|
|
143
|
+
hideLabelFromVision,
|
|
144
|
+
label,
|
|
145
|
+
value
|
|
146
|
+
} = this.props;
|
|
147
|
+
const {
|
|
148
|
+
allCategories,
|
|
149
|
+
isLoading
|
|
150
|
+
} = this.state;
|
|
151
|
+
const classes = classnames('newspack-category-autocomplete', className);
|
|
152
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
153
|
+
className: classes,
|
|
154
|
+
children: [/*#__PURE__*/_jsx(FormTokenField, {
|
|
155
|
+
onInputChange: input => this.debouncedUpdateSuggestions(input),
|
|
156
|
+
value: value.reduce((acc, item) => {
|
|
157
|
+
const categoryOrItem = typeof item === 'number' ? find(allCategories, ['id', item]) : item;
|
|
158
|
+
if (categoryOrItem) {
|
|
159
|
+
acc.push({
|
|
160
|
+
id: categoryOrItem.term_id || categoryOrItem.id,
|
|
161
|
+
value: categoryOrItem.value || categoryOrItem.name
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return acc;
|
|
165
|
+
}, []),
|
|
166
|
+
suggestions: this.getAvailableSuggestions(),
|
|
167
|
+
onChange: this.handleOnChange,
|
|
168
|
+
label: label,
|
|
169
|
+
disabled: disabled,
|
|
170
|
+
description: description,
|
|
171
|
+
hideHelpFromVision: hideHelpFromVision,
|
|
172
|
+
hideLabelFromVision: hideLabelFromVision
|
|
173
|
+
}), isLoading ? /*#__PURE__*/_jsx("span", {
|
|
174
|
+
className: "newspack-category-autocomplete__suggestions-spinner",
|
|
175
|
+
children: /*#__PURE__*/_jsx(Spinner, {})
|
|
176
|
+
}) : null]
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
CategoryAutocomplete.defaultProps = {
|
|
181
|
+
taxonomy: 'categories'
|
|
182
|
+
};
|
|
183
|
+
export default CategoryAutocomplete;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Category Autocomplete
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
.newspack-category-autocomplete {
|
|
6
|
+
position: relative;
|
|
7
|
+
|
|
8
|
+
.components-form-token-field__help {
|
|
9
|
+
display: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Within a Grid
|
|
13
|
+
|
|
14
|
+
.newspack-grid & .newspack-form-token-field__input-container {
|
|
15
|
+
margin: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Loading state spinner
|
|
19
|
+
&__suggestions-spinner {
|
|
20
|
+
position: absolute;
|
|
21
|
+
right: 1px;
|
|
22
|
+
top: calc(1.4em + 8px);
|
|
23
|
+
z-index: 2;
|
|
24
|
+
|
|
25
|
+
[class*="--label-hidden"] + & {
|
|
26
|
+
top: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.components-spinner {
|
|
30
|
+
display: block;
|
|
31
|
+
margin: 7px;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies.
|
|
3
|
+
*/
|
|
4
|
+
import { ColorPicker as ColorPickerComponent } from '@wordpress/components';
|
|
5
|
+
import { useState, useRef } from '@wordpress/element';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* External dependencies.
|
|
9
|
+
*/
|
|
10
|
+
import classnames from 'classnames';
|
|
11
|
+
import { colord, extend } from 'colord';
|
|
12
|
+
import a11yPlugin from 'colord/plugins/a11y';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies.
|
|
16
|
+
*/
|
|
17
|
+
import hooks from '../hooks';
|
|
18
|
+
import utils from '../utils';
|
|
19
|
+
import './style.scss';
|
|
20
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
extend([a11yPlugin]);
|
|
22
|
+
const {
|
|
23
|
+
InteractiveDiv
|
|
24
|
+
} = utils;
|
|
25
|
+
const ColorPicker = ({
|
|
26
|
+
label,
|
|
27
|
+
color = '#fff',
|
|
28
|
+
onChange,
|
|
29
|
+
className
|
|
30
|
+
}) => {
|
|
31
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
32
|
+
const ref = useRef();
|
|
33
|
+
const colordColor = colord(color);
|
|
34
|
+
hooks.useOnClickOutside(ref, () => setIsExpanded(false));
|
|
35
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
36
|
+
className: classnames('newspack-color-picker', className),
|
|
37
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
38
|
+
className: "newspack-color-picker__label",
|
|
39
|
+
children: label
|
|
40
|
+
}), /*#__PURE__*/_jsx(InteractiveDiv, {
|
|
41
|
+
className: 'newspack-color-picker__expander',
|
|
42
|
+
onClick: () => setIsExpanded(!isExpanded),
|
|
43
|
+
style: {
|
|
44
|
+
backgroundColor: color,
|
|
45
|
+
color: colordColor.contrast() > colordColor.contrast('#000') ? '#fff' : '#000'
|
|
46
|
+
},
|
|
47
|
+
children: color
|
|
48
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
49
|
+
className: "newspack-color-picker__main",
|
|
50
|
+
ref: ref,
|
|
51
|
+
children: isExpanded && /*#__PURE__*/_jsx(ColorPickerComponent, {
|
|
52
|
+
color: color,
|
|
53
|
+
onChange: hex => onChange(hex),
|
|
54
|
+
enableAlpha: false
|
|
55
|
+
})
|
|
56
|
+
})]
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color Picker
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
.newspack-color-picker {
|
|
6
|
+
position: relative;
|
|
7
|
+
|
|
8
|
+
&__label {
|
|
9
|
+
margin-bottom: 8px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&__expander {
|
|
13
|
+
box-shadow: inset 0 0 0 1px rgb(0 0 0 / 20%);
|
|
14
|
+
border-radius: 2px;
|
|
15
|
+
height: 64px;
|
|
16
|
+
padding: 12px;
|
|
17
|
+
text-align: right;
|
|
18
|
+
text-transform: uppercase;
|
|
19
|
+
|
|
20
|
+
&:focus-visible {
|
|
21
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
22
|
+
border-color: white;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&__main {
|
|
27
|
+
background: white;
|
|
28
|
+
box-shadow: 0 0 8px 4px rgba(black, 0.08);
|
|
29
|
+
margin: 12px 0;
|
|
30
|
+
position: absolute;
|
|
31
|
+
z-index: 2;
|
|
32
|
+
|
|
33
|
+
&:empty {
|
|
34
|
+
display: none;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const HANDOFF_KEY = 'newspack_wizard_handoff_message';
|