@planningcenter/topbar 11.2.5-rc.0 → 12.0.0-qa-834.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 CHANGED
@@ -964,8 +964,8 @@ const AppsProvider = ({
964
964
  const notificationsEnabled = !window.notificationsDisabled;
965
965
  const organizationTimeZone = ((_k = (_j = topbarResponse === null || topbarResponse === void 0 ? void 0 : topbarResponse.data) === null || _j === void 0 ? void 0 : _j.attributes) === null || _k === void 0 ? void 0 : _k.org_time_zone) || "America/Los_Angeles";
966
966
  const algoliaSearchAuth = {
967
- algoliaApplicationId: (_m = (_l = topbarResponse === null || topbarResponse === void 0 ? void 0 : topbarResponse.data) === null || _l === void 0 ? void 0 : _l.attributes) === null || _m === void 0 ? void 0 : _m.algolia_application_identifier,
968
- algoliaSearchOnlyApiKey: (_p = (_o = topbarResponse === null || topbarResponse === void 0 ? void 0 : topbarResponse.data) === null || _o === void 0 ? void 0 : _o.attributes) === null || _p === void 0 ? void 0 : _p.algolia_search_key
967
+ algoliaApplicationId: (_m = (_l = topbarResponse === null || topbarResponse === void 0 ? void 0 : topbarResponse.data) === null || _l === void 0 ? void 0 : _l.attributes) === null || _m === void 0 ? void 0 : _m.algolia_help_center_application_identifier,
968
+ algoliaSearchOnlyApiKey: (_p = (_o = topbarResponse === null || topbarResponse === void 0 ? void 0 : topbarResponse.data) === null || _o === void 0 ? void 0 : _o.attributes) === null || _p === void 0 ? void 0 : _p.algolia_help_center_search_key
969
969
  };
970
970
  const joltPromise = React.useMemo(() => {
971
971
  return resolveJoltPromise({
@@ -3478,40 +3478,44 @@ function buildPicobotSrc(origin, path) {
3478
3478
  return fragment ? `${base}#${fragment}` : base;
3479
3479
  }
3480
3480
 
3481
- const handleSearchSelect = (hit, indexName) => {
3482
- const appName = indexName.split("_")[1];
3483
- const zendeskUrl = `https://${appName}.zendesk.com/hc/${hit.locale.locale}/articles/${hit.id}`;
3484
- const newTab = window.open(zendeskUrl, "_blank");
3481
+ // The article heading lives in the deepest populated hierarchy level (lvl0 is
3482
+ // always "Planning Center").
3483
+ const hitTitle = hierarchy => (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.lvl6) || (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.lvl5) || (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.lvl4) || (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.lvl3) || (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.lvl2) || (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.lvl1) || (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.lvl0) || "";
3484
+ const handleSearchSelect = hit => {
3485
+ // `url` is always absolute (it is also the basis of objectID), so open it
3486
+ // directly. Bail out defensively if a record somehow arrives without one.
3487
+ if (!(hit === null || hit === void 0 ? void 0 : hit.url)) return;
3488
+ const newTab = window.open(hit.url, "_blank");
3485
3489
  if (newTab) {
3486
3490
  newTab.focus();
3487
3491
  }
3488
3492
  };
3493
+ // Mirrors @planningcenter/tapestry-react's Logo registry.
3494
+ const VALID_LOGO_NAMES = new Set(["api", "calendar", "check-ins", "church-center", "giving", "groups", "headcounts", "home", "login", "music-stand", "people", "planning-center", "publishing", "registrations", "services"]);
3489
3495
  const HeadingIcon = ({
3490
- sectionName,
3491
- currentAppName
3496
+ currentAppName,
3497
+ product
3492
3498
  }) => {
3493
- const lowerCaseSectionName = sectionName.toLowerCase();
3494
- if (lowerCaseSectionName === "account information" || lowerCaseSectionName === "recent updates") {
3495
- return /*#__PURE__*/React.createElement(tapestryReact.Icon, {
3496
- name: lowerCaseSectionName === "account information" ? "general.cogPerson" : "general.outlinedGenericFile",
3497
- color: "foregroundSecondary"
3498
- });
3499
- } else if (currentAppName === "Accounts") {
3499
+ const appName = product || currentAppName;
3500
+ if (!appName) return null;
3501
+ const logoName = appName.toLowerCase().replace(/\s+/g, "-");
3502
+ // Accounts has no tapestry Logo, so use the cog icon
3503
+ if (logoName === "accounts") {
3500
3504
  return /*#__PURE__*/React.createElement(tapestryReact.Icon, {
3501
3505
  name: "general.cog",
3502
3506
  color: "foregroundSecondary"
3503
3507
  });
3504
- } else {
3505
- return /*#__PURE__*/React.createElement(tapestryReact.StackView, {
3506
- width: 2,
3507
- height: 2
3508
- }, /*#__PURE__*/React.createElement(tapestryReact.Logo, {
3509
- name: currentAppName.toLowerCase().replace(/[\s]/, "-"),
3510
- size: "sm",
3511
- theme: "color",
3512
- markOnly: true
3513
- }));
3514
3508
  }
3509
+ if (!VALID_LOGO_NAMES.has(logoName)) return null;
3510
+ return /*#__PURE__*/React.createElement(tapestryReact.StackView, {
3511
+ width: 2,
3512
+ height: 2
3513
+ }, /*#__PURE__*/React.createElement(tapestryReact.Logo, {
3514
+ name: logoName,
3515
+ size: "sm",
3516
+ theme: "color",
3517
+ markOnly: true
3518
+ }));
3515
3519
  };
3516
3520
  const HitResult = ({
3517
3521
  hit,
@@ -3526,11 +3530,10 @@ const HitResult = ({
3526
3530
  color: "neutralDarker",
3527
3531
  size: 4,
3528
3532
  whiteSpace: "normal"
3529
- }, hit.title));
3533
+ }, hitTitle(hit.hierarchy)));
3530
3534
  };
3531
3535
  const CustomSearchBox = ({
3532
- currentAppName,
3533
- indexName
3536
+ currentAppName
3534
3537
  }) => {
3535
3538
  const {
3536
3539
  query,
@@ -3541,7 +3544,10 @@ const CustomSearchBox = ({
3541
3544
  results
3542
3545
  } = reactInstantsearchCore.useHits();
3543
3546
  const groups = results === null || results === void 0 ? void 0 : results.hits.reduce((acc, hit) => {
3544
- const key = hit.category.title;
3547
+ // A result with no url can't be opened, so don't render it at all.
3548
+ if (!hit.url) return acc;
3549
+ // Fall back so a record without a product never yields an "undefined" heading.
3550
+ const key = hit.product || currentAppName || "Other";
3545
3551
  if (!acc[key]) {
3546
3552
  acc[key] = [];
3547
3553
  }
@@ -3563,7 +3569,7 @@ const CustomSearchBox = ({
3563
3569
  name: "general.search"
3564
3570
  }),
3565
3571
  onChange: e => setQuery(e.target.value),
3566
- onSelect: selectedValue => handleSearchSelect(selectedValue, indexName),
3572
+ onSelect: selectedValue => handleSearchSelect(selectedValue),
3567
3573
  placement: "bottom-start"
3568
3574
  }, !hits.length && (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(tapestryReact.StackView, {
3569
3575
  axis: "horizontal",
@@ -3575,7 +3581,7 @@ const CustomSearchBox = ({
3575
3581
  size: 4,
3576
3582
  whiteSpace: "normal"
3577
3583
  }, "No results match your search")))), groups && Object.keys(groups).map(key => {
3578
- const hits = groups[key];
3584
+ const groupHits = groups[key];
3579
3585
  return /*#__PURE__*/React.createElement(React.Fragment, {
3580
3586
  key: key
3581
3587
  }, resultIndex > 0 && /*#__PURE__*/React.createElement(tapestryReact.Divider, {
@@ -3588,12 +3594,12 @@ const CustomSearchBox = ({
3588
3594
  paddingVertical: 1
3589
3595
  }, /*#__PURE__*/React.createElement(HeadingIcon, {
3590
3596
  currentAppName: currentAppName,
3591
- sectionName: key
3597
+ product: key
3592
3598
  }), /*#__PURE__*/React.createElement(tapestryReact.Text, {
3593
3599
  size: 5,
3594
3600
  color: "foregroundSecondary",
3595
3601
  fontWeight: 500
3596
- }, key)), hits.map(hit => (/*#__PURE__*/React.createElement(HitResult, {
3602
+ }, key)), groupHits.map(hit => (/*#__PURE__*/React.createElement(HitResult, {
3597
3603
  key: hit.objectID,
3598
3604
  hit: hit,
3599
3605
  index: resultIndex++
@@ -3601,8 +3607,8 @@ const CustomSearchBox = ({
3601
3607
  })));
3602
3608
  };
3603
3609
 
3610
+ const HELP_CENTER_INDEX = "help_center_english";
3604
3611
  const DocumentationSearch = ({
3605
- indexName,
3606
3612
  currentAppName
3607
3613
  }) => {
3608
3614
  const {
@@ -3613,13 +3619,13 @@ const DocumentationSearch = ({
3613
3619
  } = useStore();
3614
3620
  const searchClient = algoliasearch(algoliaApplicationId, algoliaSearchOnlyApiKey);
3615
3621
  return /*#__PURE__*/React.createElement(reactInstantsearchCore.InstantSearch, {
3616
- indexName: indexName,
3622
+ indexName: HELP_CENTER_INDEX,
3617
3623
  searchClient: searchClient
3618
3624
  }, /*#__PURE__*/React.createElement(reactInstantsearchCore.Configure, {
3619
- hitsPerPage: 5
3625
+ hitsPerPage: 5,
3626
+ optionalFilters: currentAppName ? [`product:${currentAppName}`] : undefined
3620
3627
  }), /*#__PURE__*/React.createElement(CustomSearchBox, {
3621
- currentAppName: currentAppName,
3622
- indexName: indexName
3628
+ currentAppName: currentAppName
3623
3629
  }));
3624
3630
  };
3625
3631
 
@@ -3627,6 +3633,19 @@ const {
3627
3633
  LoadingIndicator: LoadingIndicator$1,
3628
3634
  StackView: StackView$1
3629
3635
  } = addOns.components;
3636
+ function CalendlyWidget({
3637
+ url,
3638
+ pageSettings,
3639
+ prefill,
3640
+ styles
3641
+ }) {
3642
+ return url ? (/*#__PURE__*/React.createElement(reactCalendly.InlineWidget, {
3643
+ url: url,
3644
+ pageSettings: pageSettings,
3645
+ prefill: prefill,
3646
+ styles: styles
3647
+ })) : null;
3648
+ }
3630
3649
  function HelpdeskComponent({
3631
3650
  appName,
3632
3651
  closeDrawer,
@@ -3695,14 +3714,68 @@ function HelpdeskComponent({
3695
3714
  spacing: 1
3696
3715
  }, /*#__PURE__*/React.createElement(DrawerHeading, null, "Help and support"), /*#__PURE__*/React.createElement(LoadingIndicator$1, null)))),
3697
3716
  additionalComponents: {
3698
- // @ts-expect-error TODO: Relax type specification in add-ons-js to not require children
3699
- CalendlyWidget: reactCalendly.InlineWidget,
3700
- DocumentationSearch,
3701
- DrawerHeader,
3717
+ CalendlyWidget: {
3718
+ component: CalendlyWidget,
3719
+ properties: {
3720
+ pageSettings: {
3721
+ attribute: false
3722
+ },
3723
+ prefill: {
3724
+ attribute: false
3725
+ },
3726
+ styles: {
3727
+ attribute: false
3728
+ },
3729
+ url: {
3730
+ type: String
3731
+ }
3732
+ }
3733
+ },
3734
+ DocumentationSearch: {
3735
+ component: DocumentationSearch,
3736
+ properties: {
3737
+ currentAppName: {
3738
+ type: String
3739
+ },
3740
+ indexName: {
3741
+ type: String
3742
+ }
3743
+ }
3744
+ },
3745
+ DrawerHeader: {
3746
+ component: DrawerHeader,
3747
+ properties: {
3748
+ closeDrawer: {
3749
+ event: false
3750
+ }
3751
+ }
3752
+ },
3702
3753
  DrawerHeading,
3703
- PicobotIframe,
3754
+ PicobotIframe: {
3755
+ component: PicobotIframe,
3756
+ properties: {
3757
+ currentPath: {
3758
+ attribute: false
3759
+ },
3760
+ onChangePath: {
3761
+ event: false,
3762
+ type: Function
3763
+ },
3764
+ onMessage: {
3765
+ event: false,
3766
+ type: Function
3767
+ }
3768
+ }
3769
+ },
3704
3770
  ScrollContainer,
3705
- SwitchView
3771
+ SwitchView: {
3772
+ component: SwitchView,
3773
+ properties: {
3774
+ activeIndex: {
3775
+ type: Number
3776
+ }
3777
+ }
3778
+ }
3706
3779
  },
3707
3780
  args: {
3708
3781
  appName,
@@ -4306,8 +4379,13 @@ const {
4306
4379
  function NavLinkWithBadge({
4307
4380
  children,
4308
4381
  badge,
4309
- onClick,
4310
- ...rest
4382
+ borderBottomColor,
4383
+ borderBottomStyle,
4384
+ borderBottomWidth,
4385
+ color,
4386
+ fontSize,
4387
+ fontWeight,
4388
+ onClick
4311
4389
  }) {
4312
4390
  return /*#__PURE__*/React.createElement(tapestryReact.StackView, {
4313
4391
  as: "button",
@@ -4317,7 +4395,14 @@ function NavLinkWithBadge({
4317
4395
  paddingBottom: 0.75,
4318
4396
  onClick: () => onClick(),
4319
4397
  spacing: 1,
4320
- ...rest
4398
+ ...{
4399
+ borderBottomColor,
4400
+ borderBottomStyle,
4401
+ borderBottomWidth,
4402
+ color,
4403
+ fontSize,
4404
+ fontWeight
4405
+ }
4321
4406
  }, children, badge && /*#__PURE__*/React.createElement(tapestryReact.Badge, {
4322
4407
  size: "sm",
4323
4408
  fontWeight: "600",
@@ -4369,11 +4454,55 @@ function TasksComponent({
4369
4454
  spacing: 1
4370
4455
  }, /*#__PURE__*/React.createElement(DrawerHeading, null, "To do"), /*#__PURE__*/React.createElement(LoadingIndicator, null)))),
4371
4456
  additionalComponents: {
4372
- DrawerHeader,
4457
+ DrawerHeader: {
4458
+ component: DrawerHeader,
4459
+ properties: {
4460
+ closeDrawer: {
4461
+ event: false,
4462
+ type: Function
4463
+ }
4464
+ }
4465
+ },
4373
4466
  DrawerHeading,
4374
- NavLinkWithBadge,
4467
+ NavLinkWithBadge: {
4468
+ component: NavLinkWithBadge,
4469
+ properties: {
4470
+ badge: {
4471
+ attribute: false
4472
+ },
4473
+ borderBottomColor: {
4474
+ type: String
4475
+ },
4476
+ borderBottomStyle: {
4477
+ type: String
4478
+ },
4479
+ borderBottomWidth: {
4480
+ type: String
4481
+ },
4482
+ color: {
4483
+ type: String
4484
+ },
4485
+ fontSize: {
4486
+ attribute: false
4487
+ },
4488
+ fontWeight: {
4489
+ attribute: false
4490
+ },
4491
+ onClick: {
4492
+ event: false,
4493
+ type: Function
4494
+ }
4495
+ }
4496
+ },
4375
4497
  ScrollContainer,
4376
- SwitchView
4498
+ SwitchView: {
4499
+ component: SwitchView,
4500
+ properties: {
4501
+ activeIndex: {
4502
+ type: Number
4503
+ }
4504
+ }
4505
+ }
4377
4506
  },
4378
4507
  args: {
4379
4508
  closeDrawer,