@planningcenter/topbar 12.5.0-qa-998.0 → 12.5.0-qa-997.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 +79 -63
- package/dist/topbar.js.map +1 -1
- package/dist/topbar.modern.js +80 -64
- package/dist/topbar.modern.js.map +1 -1
- package/dist/topbar.module.js +80 -64
- package/dist/topbar.module.js.map +1 -1
- package/dist/topbar.umd.js +79 -63
- package/dist/topbar.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/topbar.js
CHANGED
|
@@ -3546,15 +3546,6 @@ function productSearchUrl(product, query) {
|
|
|
3546
3546
|
});
|
|
3547
3547
|
return `${window.location.origin}/~api/${product}/v2/product_search_results?${params}`;
|
|
3548
3548
|
}
|
|
3549
|
-
// The product's create page, given what the person searched for.
|
|
3550
|
-
function blankStateActionUrl({
|
|
3551
|
-
query_param = "search_query",
|
|
3552
|
-
url
|
|
3553
|
-
}, term) {
|
|
3554
|
-
const actionUrl = new URL(url);
|
|
3555
|
-
actionUrl.searchParams.set(query_param, term.trim());
|
|
3556
|
-
return actionUrl.toString();
|
|
3557
|
-
}
|
|
3558
3549
|
function groupByType({
|
|
3559
3550
|
data,
|
|
3560
3551
|
meta
|
|
@@ -3578,6 +3569,23 @@ function groupByType({
|
|
|
3578
3569
|
};
|
|
3579
3570
|
return [...groups.values()].sort((a, b) => rank(a.type) - rank(b.type));
|
|
3580
3571
|
}
|
|
3572
|
+
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");
|
|
3573
|
+
function blankStateActions({
|
|
3574
|
+
meta
|
|
3575
|
+
}) {
|
|
3576
|
+
const actions = meta === null || meta === void 0 ? void 0 : meta.blank_state_actions;
|
|
3577
|
+
return Array.isArray(actions) ? actions.filter(isBlankStateAction) : [];
|
|
3578
|
+
}
|
|
3579
|
+
// The product reads the search box's text from the action's `query_param`, to
|
|
3580
|
+
// fill in whatever it opens.
|
|
3581
|
+
function blankStateActionUrl({
|
|
3582
|
+
query_param = "search_term",
|
|
3583
|
+
url
|
|
3584
|
+
}, term) {
|
|
3585
|
+
const actionUrl = new URL(url);
|
|
3586
|
+
actionUrl.searchParams.set(query_param, term.trim());
|
|
3587
|
+
return actionUrl.toString();
|
|
3588
|
+
}
|
|
3581
3589
|
|
|
3582
3590
|
function useDebouncedValue(value, delay) {
|
|
3583
3591
|
const [debounced, setDebounced] = React.useState(value);
|
|
@@ -3590,7 +3598,6 @@ function useDebouncedValue(value, delay) {
|
|
|
3590
3598
|
|
|
3591
3599
|
const SEARCH_DEBOUNCE_MS = 300;
|
|
3592
3600
|
function useProductSearch(product, term) {
|
|
3593
|
-
var _a, _b;
|
|
3594
3601
|
const query = term.trim();
|
|
3595
3602
|
const debouncedQuery = useDebouncedValue(query, SEARCH_DEBOUNCE_MS);
|
|
3596
3603
|
const request = useCachedRequest(debouncedQuery ? productSearchUrl(product, debouncedQuery) : null);
|
|
@@ -3601,32 +3608,28 @@ function useProductSearch(product, term) {
|
|
|
3601
3608
|
// Services tab.
|
|
3602
3609
|
const visibleResponse = request.status === "done" || settledProduct === product ? response : undefined;
|
|
3603
3610
|
const groups = React.useMemo(() => visibleResponse && groupByType(visibleResponse), [visibleResponse]);
|
|
3604
|
-
const
|
|
3611
|
+
const actions = React.useMemo(() => response ? blankStateActions(response) : [], [response]);
|
|
3605
3612
|
if (!query) {
|
|
3606
3613
|
return {
|
|
3607
|
-
blankStateActions,
|
|
3608
3614
|
status: "idle"
|
|
3609
3615
|
};
|
|
3610
3616
|
} else if (query !== debouncedQuery) {
|
|
3611
3617
|
return {
|
|
3612
|
-
blankStateActions,
|
|
3613
3618
|
groups,
|
|
3614
3619
|
status: "loading"
|
|
3615
3620
|
};
|
|
3616
3621
|
} else if (request.status === "done") {
|
|
3617
3622
|
return {
|
|
3618
|
-
blankStateActions,
|
|
3623
|
+
blankStateActions: actions,
|
|
3619
3624
|
groups: groups !== null && groups !== void 0 ? groups : [],
|
|
3620
3625
|
status: "done"
|
|
3621
3626
|
};
|
|
3622
3627
|
} else if (request.status === "error") {
|
|
3623
3628
|
return {
|
|
3624
|
-
blankStateActions,
|
|
3625
3629
|
status: "error"
|
|
3626
3630
|
};
|
|
3627
3631
|
} else {
|
|
3628
3632
|
return {
|
|
3629
|
-
blankStateActions,
|
|
3630
3633
|
groups,
|
|
3631
3634
|
status: "loading"
|
|
3632
3635
|
};
|
|
@@ -4720,6 +4723,39 @@ function capitalize(word) {
|
|
|
4720
4723
|
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
4721
4724
|
}
|
|
4722
4725
|
|
|
4726
|
+
// The first action is the button, and any others wait behind its caret.
|
|
4727
|
+
function BlankStateActions({
|
|
4728
|
+
actions,
|
|
4729
|
+
onOpen,
|
|
4730
|
+
term
|
|
4731
|
+
}) {
|
|
4732
|
+
const [primary, ...others] = actions;
|
|
4733
|
+
if (!primary) return null;
|
|
4734
|
+
const primaryLink = /*#__PURE__*/React.createElement(tapestry.Link, {
|
|
4735
|
+
href: blankStateActionUrl(primary, term),
|
|
4736
|
+
kind: "neutral",
|
|
4737
|
+
label: primary.label,
|
|
4738
|
+
onClick: onOpen,
|
|
4739
|
+
prefix: /*#__PURE__*/React.createElement(Icon, {
|
|
4740
|
+
name: "general.plus"
|
|
4741
|
+
})
|
|
4742
|
+
});
|
|
4743
|
+
if (others.length === 0) return primaryLink;
|
|
4744
|
+
return /*#__PURE__*/React.createElement(tapestry.ButtonGroup, {
|
|
4745
|
+
"aria-label": "Create"
|
|
4746
|
+
}, primaryLink, /*#__PURE__*/React.createElement(tapestry.Dropdown, null, /*#__PURE__*/React.createElement(tapestry.DropdownTrigger, null, /*#__PURE__*/React.createElement(tapestry.DropdownIconButton, {
|
|
4747
|
+
"aria-label": "More to create",
|
|
4748
|
+
icon: null,
|
|
4749
|
+
kind: "neutral"
|
|
4750
|
+
})), /*#__PURE__*/React.createElement(tapestry.DropdownMenu, {
|
|
4751
|
+
placement: "bottom start"
|
|
4752
|
+
}, others.map(action => (/*#__PURE__*/React.createElement(tapestry.DropdownLink, {
|
|
4753
|
+
href: blankStateActionUrl(action, term),
|
|
4754
|
+
id: action.url,
|
|
4755
|
+
key: action.url
|
|
4756
|
+
}, action.label))))));
|
|
4757
|
+
}
|
|
4758
|
+
|
|
4723
4759
|
var styles$j = {"container":"container-YDdM1","hint":"hint-017Rd","keycap":"keycap-ENJM2","labels":"labels-GHPqL","copied":"copied-DUFa1"};
|
|
4724
4760
|
|
|
4725
4761
|
const SYMBOLS = {
|
|
@@ -5402,7 +5438,7 @@ function BlankStateRecentlyVisited(props) {
|
|
|
5402
5438
|
var styles$f = {"blank_state":"blank_state-wMOWN","image":"image-uy0Fd"};
|
|
5403
5439
|
|
|
5404
5440
|
function BlankState$1({
|
|
5405
|
-
|
|
5441
|
+
action,
|
|
5406
5442
|
image,
|
|
5407
5443
|
role,
|
|
5408
5444
|
subtitle,
|
|
@@ -5420,7 +5456,7 @@ function BlankState$1({
|
|
|
5420
5456
|
direction: "column",
|
|
5421
5457
|
align: "center",
|
|
5422
5458
|
gap: 1
|
|
5423
|
-
}, /*#__PURE__*/React.createElement("h2", null, title), /*#__PURE__*/React.createElement("p", null, subtitle)),
|
|
5459
|
+
}, /*#__PURE__*/React.createElement("h2", null, title), /*#__PURE__*/React.createElement("p", null, subtitle)), action);
|
|
5424
5460
|
}
|
|
5425
5461
|
|
|
5426
5462
|
function EndOfResultsObserver({
|
|
@@ -6083,42 +6119,6 @@ function BlankStateNoResults(props) {
|
|
|
6083
6119
|
})));
|
|
6084
6120
|
}
|
|
6085
6121
|
|
|
6086
|
-
// The first action is a button, and any others are in a menu beside it. They
|
|
6087
|
-
// open with a full page load, like a result does.
|
|
6088
|
-
function BlankStateActions({
|
|
6089
|
-
actions,
|
|
6090
|
-
term
|
|
6091
|
-
}) {
|
|
6092
|
-
const [primary, ...others] = actions;
|
|
6093
|
-
const primaryLink = primary ? (/*#__PURE__*/React.createElement(tapestry.Link, {
|
|
6094
|
-
"data-turbo": "false",
|
|
6095
|
-
href: blankStateActionUrl(primary, term),
|
|
6096
|
-
kind: "neutral",
|
|
6097
|
-
label: primary.label,
|
|
6098
|
-
prefix: /*#__PURE__*/React.createElement(Icon, {
|
|
6099
|
-
name: "general.plus"
|
|
6100
|
-
}),
|
|
6101
|
-
size: "sm"
|
|
6102
|
-
})) : null;
|
|
6103
|
-
return others.length > 0 ? (/*#__PURE__*/React.createElement(tapestry.ButtonGroup, {
|
|
6104
|
-
"aria-label": "Create"
|
|
6105
|
-
}, primaryLink, /*#__PURE__*/React.createElement(tapestry.Dropdown, null, /*#__PURE__*/React.createElement(tapestry.DropdownTrigger, null, /*#__PURE__*/React.createElement(tapestry.IconButton, {
|
|
6106
|
-
"aria-label": "More ways to create",
|
|
6107
|
-
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
6108
|
-
name: "general.downCaret"
|
|
6109
|
-
}),
|
|
6110
|
-
kind: "neutral",
|
|
6111
|
-
size: "sm"
|
|
6112
|
-
})), /*#__PURE__*/React.createElement(tapestry.DropdownMenu, {
|
|
6113
|
-
placement: "bottom end"
|
|
6114
|
-
}, others.map(action => (/*#__PURE__*/React.createElement(tapestry.DropdownLink, {
|
|
6115
|
-
"data-turbo": "false",
|
|
6116
|
-
href: blankStateActionUrl(action, term),
|
|
6117
|
-
id: action.label,
|
|
6118
|
-
key: action.label
|
|
6119
|
-
}, action.label))))))) : primaryLink;
|
|
6120
|
-
}
|
|
6121
|
-
|
|
6122
6122
|
var styles$b = {"spinner":"spinner-b5tlz"};
|
|
6123
6123
|
|
|
6124
6124
|
function LoadingSpinner({
|
|
@@ -6136,8 +6136,8 @@ function LoadingSpinner({
|
|
|
6136
6136
|
}
|
|
6137
6137
|
|
|
6138
6138
|
function SearchResults({
|
|
6139
|
-
blankStateActions,
|
|
6140
6139
|
label,
|
|
6140
|
+
noResultsAction,
|
|
6141
6141
|
sections,
|
|
6142
6142
|
status,
|
|
6143
6143
|
term,
|
|
@@ -6181,13 +6181,11 @@ function SearchResults({
|
|
|
6181
6181
|
if (sections.length === 0) {
|
|
6182
6182
|
// The panel's result count announces this, so it isn't read twice.
|
|
6183
6183
|
return /*#__PURE__*/React.createElement(BlankState$1, {
|
|
6184
|
+
action: noResultsAction,
|
|
6184
6185
|
image: /*#__PURE__*/React.createElement(BlankStateNoResults, null),
|
|
6185
6186
|
subtitle: "Clear search and try again.",
|
|
6186
6187
|
title: `No results for “${term.trim()}”`
|
|
6187
|
-
}
|
|
6188
|
-
actions: blankStateActions,
|
|
6189
|
-
term: term
|
|
6190
|
-
}));
|
|
6188
|
+
});
|
|
6191
6189
|
}
|
|
6192
6190
|
return /*#__PURE__*/React.createElement(ResultListbox, {
|
|
6193
6191
|
busy: false,
|
|
@@ -6240,6 +6238,20 @@ function SearchPanel({
|
|
|
6240
6238
|
const inputRef = React.useRef(null);
|
|
6241
6239
|
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);
|
|
6242
6240
|
const [announceHighlight, setAnnounceHighlight] = React.useState(false);
|
|
6241
|
+
const blankStateActions = hasTerm && search.status === "done" && items.length === 0 ? search.blankStateActions : [];
|
|
6242
|
+
// With nothing to highlight, Enter takes the first thing the product offers
|
|
6243
|
+
// to create instead, the way the old People search added the person.
|
|
6244
|
+
const handleKeyDown = event => {
|
|
6245
|
+
const [action] = blankStateActions;
|
|
6246
|
+
if (event.key === "Enter" && action && !event.nativeEvent.isComposing) {
|
|
6247
|
+
event.preventDefault();
|
|
6248
|
+
open(blankStateActionUrl(action, term), {
|
|
6249
|
+
newTab: hasCommandKey(event)
|
|
6250
|
+
});
|
|
6251
|
+
} else {
|
|
6252
|
+
navigation.handleKeyDown(event);
|
|
6253
|
+
}
|
|
6254
|
+
};
|
|
6243
6255
|
// The tabs keep focus while arrowing through results, but only the focused
|
|
6244
6256
|
// input can point screen readers at the highlight, so from the tabs it's
|
|
6245
6257
|
// announced instead. Typing goes back to the input, keystroke and all.
|
|
@@ -6249,16 +6261,20 @@ function SearchPanel({
|
|
|
6249
6261
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
6250
6262
|
} else if (verticalStep(event.key)) {
|
|
6251
6263
|
setAnnounceHighlight(true);
|
|
6252
|
-
|
|
6264
|
+
handleKeyDown(event);
|
|
6253
6265
|
} else {
|
|
6254
|
-
|
|
6266
|
+
handleKeyDown(event);
|
|
6255
6267
|
}
|
|
6256
6268
|
};
|
|
6257
6269
|
const results = hasTerm ? (/*#__PURE__*/React.createElement(SearchResults, {
|
|
6258
|
-
blankStateActions: search.blankStateActions,
|
|
6259
6270
|
highlightedIndex: highlightedIndex,
|
|
6260
6271
|
id: listboxId,
|
|
6261
6272
|
label: `Results from Planning Center ${product.appName}`,
|
|
6273
|
+
noResultsAction: /*#__PURE__*/React.createElement(BlankStateActions, {
|
|
6274
|
+
actions: blankStateActions,
|
|
6275
|
+
onOpen: onOpenResult,
|
|
6276
|
+
term: term
|
|
6277
|
+
}),
|
|
6262
6278
|
onHighlight: navigation.highlightIndex,
|
|
6263
6279
|
onOpen: onOpenResult,
|
|
6264
6280
|
sections: sections,
|
|
@@ -6280,7 +6296,7 @@ function SearchPanel({
|
|
|
6280
6296
|
onChange: setTerm,
|
|
6281
6297
|
onClose: onClose,
|
|
6282
6298
|
onFocus: () => setAnnounceHighlight(false),
|
|
6283
|
-
onKeyDown:
|
|
6299
|
+
onKeyDown: handleKeyDown,
|
|
6284
6300
|
value: term
|
|
6285
6301
|
}), mobile ? (/*#__PURE__*/React.createElement(ProductSelect, {
|
|
6286
6302
|
onSelect: setSelectedSlug,
|