@planningcenter/topbar 12.6.0-rc.0 → 12.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/topbar.js +78 -4
- package/dist/topbar.js.map +1 -1
- package/dist/topbar.modern.js +84 -10
- package/dist/topbar.modern.js.map +1 -1
- package/dist/topbar.module.js +84 -10
- package/dist/topbar.module.js.map +1 -1
- package/dist/topbar.umd.js +78 -4
- package/dist/topbar.umd.js.map +1 -1
- package/package.json +2 -3
package/dist/topbar.umd.js
CHANGED
|
@@ -3553,6 +3553,23 @@ true;
|
|
|
3553
3553
|
};
|
|
3554
3554
|
return [...groups.values()].sort((a, b) => rank(a.type) - rank(b.type));
|
|
3555
3555
|
}
|
|
3556
|
+
const isBlankStateAction = action => typeof action === "object" && action !== null && "label" in action && "url" in action && typeof action.label === "string" && typeof action.url === "string" && (!("query_param" in action) || typeof action.query_param === "string");
|
|
3557
|
+
function blankStateActions({
|
|
3558
|
+
meta
|
|
3559
|
+
}) {
|
|
3560
|
+
const actions = meta === null || meta === void 0 ? void 0 : meta.blank_state_actions;
|
|
3561
|
+
return Array.isArray(actions) ? actions.filter(isBlankStateAction) : [];
|
|
3562
|
+
}
|
|
3563
|
+
// The product reads the search box's text from the action's `query_param`, to
|
|
3564
|
+
// fill in whatever it opens.
|
|
3565
|
+
function blankStateActionUrl({
|
|
3566
|
+
query_param = "search_term",
|
|
3567
|
+
url
|
|
3568
|
+
}, term) {
|
|
3569
|
+
const actionUrl = new URL(url);
|
|
3570
|
+
actionUrl.searchParams.set(query_param, term.trim());
|
|
3571
|
+
return actionUrl.toString();
|
|
3572
|
+
}
|
|
3556
3573
|
|
|
3557
3574
|
function useDebouncedValue(value, delay) {
|
|
3558
3575
|
const [debounced, setDebounced] = React.useState(value);
|
|
@@ -3575,6 +3592,7 @@ true;
|
|
|
3575
3592
|
// Services tab.
|
|
3576
3593
|
const visibleResponse = request.status === "done" || settledProduct === product ? response : undefined;
|
|
3577
3594
|
const groups = React.useMemo(() => visibleResponse && groupByType(visibleResponse), [visibleResponse]);
|
|
3595
|
+
const actions = React.useMemo(() => response ? blankStateActions(response) : [], [response]);
|
|
3578
3596
|
if (!query) {
|
|
3579
3597
|
return {
|
|
3580
3598
|
status: "idle"
|
|
@@ -3586,6 +3604,7 @@ true;
|
|
|
3586
3604
|
};
|
|
3587
3605
|
} else if (request.status === "done") {
|
|
3588
3606
|
return {
|
|
3607
|
+
blankStateActions: actions,
|
|
3589
3608
|
groups: groups !== null && groups !== void 0 ? groups : [],
|
|
3590
3609
|
status: "done"
|
|
3591
3610
|
};
|
|
@@ -4688,6 +4707,39 @@ true;
|
|
|
4688
4707
|
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
4689
4708
|
}
|
|
4690
4709
|
|
|
4710
|
+
// The first action is the button, and any others wait behind its caret.
|
|
4711
|
+
function BlankStateActions({
|
|
4712
|
+
actions,
|
|
4713
|
+
onOpen,
|
|
4714
|
+
term
|
|
4715
|
+
}) {
|
|
4716
|
+
const [primary, ...others] = actions;
|
|
4717
|
+
if (!primary) return null;
|
|
4718
|
+
const primaryLink = /*#__PURE__*/React.createElement(tapestry.Link, {
|
|
4719
|
+
href: blankStateActionUrl(primary, term),
|
|
4720
|
+
kind: "neutral",
|
|
4721
|
+
label: primary.label,
|
|
4722
|
+
onClick: onOpen,
|
|
4723
|
+
prefix: /*#__PURE__*/React.createElement(Icon, {
|
|
4724
|
+
name: "general.plus"
|
|
4725
|
+
})
|
|
4726
|
+
});
|
|
4727
|
+
if (others.length === 0) return primaryLink;
|
|
4728
|
+
return /*#__PURE__*/React.createElement(tapestry.ButtonGroup, {
|
|
4729
|
+
"aria-label": "Create"
|
|
4730
|
+
}, primaryLink, /*#__PURE__*/React.createElement(tapestry.Dropdown, null, /*#__PURE__*/React.createElement(tapestry.DropdownTrigger, null, /*#__PURE__*/React.createElement(tapestry.DropdownIconButton, {
|
|
4731
|
+
"aria-label": "More to create",
|
|
4732
|
+
icon: null,
|
|
4733
|
+
kind: "neutral"
|
|
4734
|
+
})), /*#__PURE__*/React.createElement(tapestry.DropdownMenu, {
|
|
4735
|
+
placement: "bottom start"
|
|
4736
|
+
}, others.map(action => (/*#__PURE__*/React.createElement(tapestry.DropdownLink, {
|
|
4737
|
+
href: blankStateActionUrl(action, term),
|
|
4738
|
+
id: action.url,
|
|
4739
|
+
key: action.url
|
|
4740
|
+
}, action.label))))));
|
|
4741
|
+
}
|
|
4742
|
+
|
|
4691
4743
|
var styles$j = {"container":"container-YDdM1","hint":"hint-017Rd","keycap":"keycap-ENJM2","labels":"labels-GHPqL","copied":"copied-DUFa1"};
|
|
4692
4744
|
|
|
4693
4745
|
const SYMBOLS = {
|
|
@@ -5370,6 +5422,7 @@ true;
|
|
|
5370
5422
|
var styles$f = {"blank_state":"blank_state-wMOWN","image":"image-uy0Fd"};
|
|
5371
5423
|
|
|
5372
5424
|
function BlankState$1({
|
|
5425
|
+
action,
|
|
5373
5426
|
image,
|
|
5374
5427
|
role,
|
|
5375
5428
|
subtitle,
|
|
@@ -5387,7 +5440,7 @@ true;
|
|
|
5387
5440
|
direction: "column",
|
|
5388
5441
|
align: "center",
|
|
5389
5442
|
gap: 1
|
|
5390
|
-
}, /*#__PURE__*/React.createElement("h2", null, title), /*#__PURE__*/React.createElement("p", null, subtitle)));
|
|
5443
|
+
}, /*#__PURE__*/React.createElement("h2", null, title), /*#__PURE__*/React.createElement("p", null, subtitle)), action);
|
|
5391
5444
|
}
|
|
5392
5445
|
|
|
5393
5446
|
function EndOfResultsObserver({
|
|
@@ -6068,6 +6121,7 @@ true;
|
|
|
6068
6121
|
|
|
6069
6122
|
function SearchResults({
|
|
6070
6123
|
label,
|
|
6124
|
+
noResultsAction,
|
|
6071
6125
|
sections,
|
|
6072
6126
|
status,
|
|
6073
6127
|
term,
|
|
@@ -6111,6 +6165,7 @@ true;
|
|
|
6111
6165
|
if (sections.length === 0) {
|
|
6112
6166
|
// The panel's result count announces this, so it isn't read twice.
|
|
6113
6167
|
return /*#__PURE__*/React.createElement(BlankState$1, {
|
|
6168
|
+
action: noResultsAction,
|
|
6114
6169
|
image: /*#__PURE__*/React.createElement(BlankStateNoResults, null),
|
|
6115
6170
|
subtitle: "Clear search and try again.",
|
|
6116
6171
|
title: `No results for “${term.trim()}”`
|
|
@@ -6167,6 +6222,20 @@ true;
|
|
|
6167
6222
|
const inputRef = React.useRef(null);
|
|
6168
6223
|
const resultCount = useAnnouncement(hasTerm && search.status === "done" ? `${items.length === 0 ? "No results" : `${items.length} ${items.length === 1 ? "result" : "results"}`} for “${term.trim()}” in ${product.appName}` : null);
|
|
6169
6224
|
const [announceHighlight, setAnnounceHighlight] = React.useState(false);
|
|
6225
|
+
const blankStateActions = hasTerm && search.status === "done" && items.length === 0 ? search.blankStateActions : [];
|
|
6226
|
+
// With nothing to highlight, Enter takes the first thing the product offers
|
|
6227
|
+
// to create instead, the way the old People search added the person.
|
|
6228
|
+
const handleKeyDown = event => {
|
|
6229
|
+
const [action] = blankStateActions;
|
|
6230
|
+
if (event.key === "Enter" && action && !event.nativeEvent.isComposing) {
|
|
6231
|
+
event.preventDefault();
|
|
6232
|
+
open(blankStateActionUrl(action, term), {
|
|
6233
|
+
newTab: hasCommandKey(event)
|
|
6234
|
+
});
|
|
6235
|
+
} else {
|
|
6236
|
+
navigation.handleKeyDown(event);
|
|
6237
|
+
}
|
|
6238
|
+
};
|
|
6170
6239
|
// The tabs keep focus while arrowing through results, but only the focused
|
|
6171
6240
|
// input can point screen readers at the highlight, so from the tabs it's
|
|
6172
6241
|
// announced instead. Typing goes back to the input, keystroke and all.
|
|
@@ -6176,15 +6245,20 @@ true;
|
|
|
6176
6245
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
6177
6246
|
} else if (verticalStep(event.key)) {
|
|
6178
6247
|
setAnnounceHighlight(true);
|
|
6179
|
-
|
|
6248
|
+
handleKeyDown(event);
|
|
6180
6249
|
} else {
|
|
6181
|
-
|
|
6250
|
+
handleKeyDown(event);
|
|
6182
6251
|
}
|
|
6183
6252
|
};
|
|
6184
6253
|
const results = hasTerm ? (/*#__PURE__*/React.createElement(SearchResults, {
|
|
6185
6254
|
highlightedIndex: highlightedIndex,
|
|
6186
6255
|
id: listboxId,
|
|
6187
6256
|
label: `Results from Planning Center ${product.appName}`,
|
|
6257
|
+
noResultsAction: /*#__PURE__*/React.createElement(BlankStateActions, {
|
|
6258
|
+
actions: blankStateActions,
|
|
6259
|
+
onOpen: onOpenResult,
|
|
6260
|
+
term: term
|
|
6261
|
+
}),
|
|
6188
6262
|
onHighlight: navigation.highlightIndex,
|
|
6189
6263
|
onOpen: onOpenResult,
|
|
6190
6264
|
sections: sections,
|
|
@@ -6206,7 +6280,7 @@ true;
|
|
|
6206
6280
|
onChange: setTerm,
|
|
6207
6281
|
onClose: onClose,
|
|
6208
6282
|
onFocus: () => setAnnounceHighlight(false),
|
|
6209
|
-
onKeyDown:
|
|
6283
|
+
onKeyDown: handleKeyDown,
|
|
6210
6284
|
value: term
|
|
6211
6285
|
}), mobile ? (/*#__PURE__*/React.createElement(ProductSelect, {
|
|
6212
6286
|
onSelect: setSelectedSlug,
|