achery-ui 0.5.4 → 0.5.6

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/index.cjs CHANGED
@@ -37,6 +37,12 @@ var RadixDialog__namespace = /*#__PURE__*/_interopNamespace(RadixDialog);
37
37
  var RadixCheckbox__namespace = /*#__PURE__*/_interopNamespace(RadixCheckbox);
38
38
  var RadixDropdownMenu__namespace = /*#__PURE__*/_interopNamespace(RadixDropdownMenu);
39
39
 
40
+ var AppBarSearchContext = react.createContext(null);
41
+ var AppBarSearchProvider = ({ children }) => {
42
+ const [searchConfig, setSearchConfig] = react.useState(null);
43
+ return /* @__PURE__ */ jsxRuntime.jsx(AppBarSearchContext.Provider, { value: { searchConfig, setSearchConfig }, children });
44
+ };
45
+ var useAppBarSearch = () => react.useContext(AppBarSearchContext);
40
46
  var STORAGE_KEY = "achery-theme-mode";
41
47
  var ThemeContext = react.createContext(null);
42
48
  function getSystemTheme() {
@@ -97,7 +103,7 @@ function AcheryProvider({
97
103
  delete html.dataset["acheryRoot"];
98
104
  };
99
105
  }, [resolvedTheme, accent]);
100
- return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: { mode, theme: resolvedTheme, setTheme, toggleTheme, accent, setAccent }, children: /* @__PURE__ */ jsxRuntime.jsx(
106
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: { mode, theme: resolvedTheme, setTheme, toggleTheme, accent, setAccent }, children: /* @__PURE__ */ jsxRuntime.jsx(AppBarSearchProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
101
107
  "div",
102
108
  {
103
109
  "data-achery-root": "",
@@ -107,7 +113,7 @@ function AcheryProvider({
107
113
  style,
108
114
  children
109
115
  }
110
- ) });
116
+ ) }) });
111
117
  }
112
118
  function useTheme() {
113
119
  const ctx = react.useContext(ThemeContext);
@@ -707,11 +713,14 @@ function Tooltip({
707
713
 
708
714
  // src/components/Sidebar/Sidebar.css.ts
709
715
  var backdrop = "Sidebar_backdrop__1n0xxfc2";
716
+ var bottomSlot = "Sidebar_bottomSlot__1n0xxfc9";
710
717
  var collapseToggle = "Sidebar_collapseToggle__1n0xxfc3";
711
- var countAccent = "Sidebar_countAccent__1n0xxfc9";
718
+ var countAccent = "Sidebar_countAccent__1n0xxfcc";
712
719
  var footer = "Sidebar_footer__1n0xxfc8";
713
720
  var group = "Sidebar_group__1n0xxfc4";
714
721
  var groupLabel = "Sidebar_groupLabel__1n0xxfc5";
722
+ var mobileSearch = "Sidebar_mobileSearch__1n0xxfca";
723
+ var mobileSearchInput = "Sidebar_mobileSearchInput__1n0xxfcb";
715
724
  var navItem = "Sidebar_navItem__1n0xxfc6";
716
725
  var navItemCount = "Sidebar_navItemCount__1n0xxfc7";
717
726
  var sidebar = "Sidebar_sidebar__1n0xxfc0";
@@ -729,6 +738,8 @@ function Sidebar({
729
738
  className
730
739
  }) {
731
740
  const isMobileMode = mobileOpen !== void 0;
741
+ const searchCtx = useAppBarSearch();
742
+ const searchConfig = searchCtx?.searchConfig ?? null;
732
743
  const nav = /* @__PURE__ */ jsxRuntime.jsxs(
733
744
  "nav",
734
745
  {
@@ -762,7 +773,26 @@ function Sidebar({
762
773
  },
763
774
  i
764
775
  )),
765
- footer3 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: footer, children: footer3 })
776
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: bottomSlot, children: [
777
+ searchConfig && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: mobileSearch, children: [
778
+ /* @__PURE__ */ jsxRuntime.jsx(Glyph, { name: "compass", size: 12, "aria-hidden": "true" }),
779
+ /* @__PURE__ */ jsxRuntime.jsx(
780
+ "input",
781
+ {
782
+ type: "search",
783
+ placeholder: searchConfig.placeholder,
784
+ className: mobileSearchInput,
785
+ "aria-label": "Search",
786
+ onFocus: () => searchConfig.onSearchFocus?.(),
787
+ onKeyDown: (e) => {
788
+ if (e.key === "Enter") searchConfig.onSearch?.(e.target.value);
789
+ }
790
+ }
791
+ ),
792
+ searchConfig.kbd && /* @__PURE__ */ jsxRuntime.jsx("span", { children: searchConfig.kbd })
793
+ ] }),
794
+ footer3 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: footer, children: footer3 })
795
+ ] })
766
796
  ]
767
797
  }
768
798
  );
@@ -871,18 +901,19 @@ function Avatar({ initials: initials2, size = "md", tone = "neutral", className
871
901
  }
872
902
 
873
903
  // src/components/AppBar/AppBar.css.ts
874
- var accentPicker = "AppBar_accentPicker__uqki99a";
875
- var accentSwatch = "AppBar_accentSwatch__uqki99b";
876
- var actions = "AppBar_actions__uqki998";
877
- var actionsInner = "AppBar_actionsInner__uqki999";
904
+ var accentPicker = "AppBar_accentPicker__uqki99b";
905
+ var accentSwatch = "AppBar_accentSwatch__uqki99c";
906
+ var actions = "AppBar_actions__uqki999";
907
+ var actionsInner = "AppBar_actionsInner__uqki99a";
878
908
  var appBar = "AppBar_appBar__uqki990";
879
909
  var brand = "AppBar_brand__uqki991";
880
910
  var brandDivider = "AppBar_brandDivider__uqki993";
881
911
  var brandName = "AppBar_brandName__uqki992";
882
912
  var brandSub = "AppBar_brandSub__uqki994";
883
- var searchArea = "AppBar_searchArea__uqki995";
884
- var searchInput2 = "AppBar_searchInput__uqki996";
885
- var searchKbd = "AppBar_searchKbd__uqki997";
913
+ var searchArea = "AppBar_searchArea__uqki996";
914
+ var searchInput2 = "AppBar_searchInput__uqki997";
915
+ var searchKbd = "AppBar_searchKbd__uqki998";
916
+ var searchSpacer = "AppBar_searchSpacer__uqki995";
886
917
  function AppBar({
887
918
  brandName: brandName2 = "Achery",
888
919
  brandSub: brandSub2,
@@ -901,6 +932,17 @@ function AppBar({
901
932
  onSearchFocus,
902
933
  className
903
934
  }) {
935
+ const searchCtx = useAppBarSearch();
936
+ react.useEffect(() => {
937
+ if (!searchCtx || !showSearch) return;
938
+ searchCtx.setSearchConfig({
939
+ placeholder: searchPlaceholder,
940
+ ...searchKbd2 !== void 0 && { kbd: searchKbd2 },
941
+ ...onSearch !== void 0 && { onSearch },
942
+ ...onSearchFocus !== void 0 && { onSearchFocus }
943
+ });
944
+ return () => searchCtx.setSearchConfig(null);
945
+ }, [showSearch, searchPlaceholder, searchKbd2, onSearch, onSearchFocus]);
904
946
  return /* @__PURE__ */ jsxRuntime.jsxs("header", { className: [appBar, className].filter(Boolean).join(" "), children: [
905
947
  onMenuClick && /* @__PURE__ */ jsxRuntime.jsx(
906
948
  Button,
@@ -920,7 +962,7 @@ function AppBar({
920
962
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: brandSub, children: brandSub2 })
921
963
  ] })
922
964
  ] }),
923
- showSearch && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: searchArea, children: [
965
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: showSearch ? searchArea : searchSpacer, children: showSearch && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
924
966
  /* @__PURE__ */ jsxRuntime.jsx(Glyph, { name: "compass", size: 12, "aria-hidden": "true" }),
925
967
  /* @__PURE__ */ jsxRuntime.jsx(
926
968
  "input",
@@ -936,7 +978,7 @@ function AppBar({
936
978
  }
937
979
  ),
938
980
  searchKbd2 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: searchKbd, children: searchKbd2 })
939
- ] }),
981
+ ] }) }),
940
982
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: actions, children: [
941
983
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: actionsInner, children: [
942
984
  onAccentChange && /* @__PURE__ */ jsxRuntime.jsx("div", { className: accentPicker, role: "group", "aria-label": "Brand colour", children: chunkLJ24EJ3N_cjs.accentColorNames.map((name) => /* @__PURE__ */ jsxRuntime.jsx(