achery-ui 0.5.4 → 0.5.5

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);
@@ -708,10 +714,12 @@ function Tooltip({
708
714
  // src/components/Sidebar/Sidebar.css.ts
709
715
  var backdrop = "Sidebar_backdrop__1n0xxfc2";
710
716
  var collapseToggle = "Sidebar_collapseToggle__1n0xxfc3";
711
- var countAccent = "Sidebar_countAccent__1n0xxfc9";
717
+ var countAccent = "Sidebar_countAccent__1n0xxfcb";
712
718
  var footer = "Sidebar_footer__1n0xxfc8";
713
719
  var group = "Sidebar_group__1n0xxfc4";
714
720
  var groupLabel = "Sidebar_groupLabel__1n0xxfc5";
721
+ var mobileSearch = "Sidebar_mobileSearch__1n0xxfc9";
722
+ var mobileSearchInput = "Sidebar_mobileSearchInput__1n0xxfca";
715
723
  var navItem = "Sidebar_navItem__1n0xxfc6";
716
724
  var navItemCount = "Sidebar_navItemCount__1n0xxfc7";
717
725
  var sidebar = "Sidebar_sidebar__1n0xxfc0";
@@ -729,6 +737,8 @@ function Sidebar({
729
737
  className
730
738
  }) {
731
739
  const isMobileMode = mobileOpen !== void 0;
740
+ const searchCtx = useAppBarSearch();
741
+ const searchConfig = searchCtx?.searchConfig ?? null;
732
742
  const nav = /* @__PURE__ */ jsxRuntime.jsxs(
733
743
  "nav",
734
744
  {
@@ -762,6 +772,23 @@ function Sidebar({
762
772
  },
763
773
  i
764
774
  )),
775
+ searchConfig && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: mobileSearch, children: [
776
+ /* @__PURE__ */ jsxRuntime.jsx(Glyph, { name: "compass", size: 12, "aria-hidden": "true" }),
777
+ /* @__PURE__ */ jsxRuntime.jsx(
778
+ "input",
779
+ {
780
+ type: "search",
781
+ placeholder: searchConfig.placeholder,
782
+ className: mobileSearchInput,
783
+ "aria-label": "Search",
784
+ onFocus: () => searchConfig.onSearchFocus?.(),
785
+ onKeyDown: (e) => {
786
+ if (e.key === "Enter") searchConfig.onSearch?.(e.target.value);
787
+ }
788
+ }
789
+ ),
790
+ searchConfig.kbd && /* @__PURE__ */ jsxRuntime.jsx("span", { children: searchConfig.kbd })
791
+ ] }),
765
792
  footer3 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: footer, children: footer3 })
766
793
  ]
767
794
  }
@@ -871,18 +898,19 @@ function Avatar({ initials: initials2, size = "md", tone = "neutral", className
871
898
  }
872
899
 
873
900
  // 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";
901
+ var accentPicker = "AppBar_accentPicker__uqki99b";
902
+ var accentSwatch = "AppBar_accentSwatch__uqki99c";
903
+ var actions = "AppBar_actions__uqki999";
904
+ var actionsInner = "AppBar_actionsInner__uqki99a";
878
905
  var appBar = "AppBar_appBar__uqki990";
879
906
  var brand = "AppBar_brand__uqki991";
880
907
  var brandDivider = "AppBar_brandDivider__uqki993";
881
908
  var brandName = "AppBar_brandName__uqki992";
882
909
  var brandSub = "AppBar_brandSub__uqki994";
883
- var searchArea = "AppBar_searchArea__uqki995";
884
- var searchInput2 = "AppBar_searchInput__uqki996";
885
- var searchKbd = "AppBar_searchKbd__uqki997";
910
+ var searchArea = "AppBar_searchArea__uqki996";
911
+ var searchInput2 = "AppBar_searchInput__uqki997";
912
+ var searchKbd = "AppBar_searchKbd__uqki998";
913
+ var searchSpacer = "AppBar_searchSpacer__uqki995";
886
914
  function AppBar({
887
915
  brandName: brandName2 = "Achery",
888
916
  brandSub: brandSub2,
@@ -901,6 +929,17 @@ function AppBar({
901
929
  onSearchFocus,
902
930
  className
903
931
  }) {
932
+ const searchCtx = useAppBarSearch();
933
+ react.useEffect(() => {
934
+ if (!searchCtx || !showSearch) return;
935
+ searchCtx.setSearchConfig({
936
+ placeholder: searchPlaceholder,
937
+ ...searchKbd2 !== void 0 && { kbd: searchKbd2 },
938
+ ...onSearch !== void 0 && { onSearch },
939
+ ...onSearchFocus !== void 0 && { onSearchFocus }
940
+ });
941
+ return () => searchCtx.setSearchConfig(null);
942
+ }, [showSearch, searchPlaceholder, searchKbd2, onSearch, onSearchFocus]);
904
943
  return /* @__PURE__ */ jsxRuntime.jsxs("header", { className: [appBar, className].filter(Boolean).join(" "), children: [
905
944
  onMenuClick && /* @__PURE__ */ jsxRuntime.jsx(
906
945
  Button,
@@ -920,7 +959,7 @@ function AppBar({
920
959
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: brandSub, children: brandSub2 })
921
960
  ] })
922
961
  ] }),
923
- showSearch && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: searchArea, children: [
962
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: showSearch ? searchArea : searchSpacer, children: showSearch && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
924
963
  /* @__PURE__ */ jsxRuntime.jsx(Glyph, { name: "compass", size: 12, "aria-hidden": "true" }),
925
964
  /* @__PURE__ */ jsxRuntime.jsx(
926
965
  "input",
@@ -936,7 +975,7 @@ function AppBar({
936
975
  }
937
976
  ),
938
977
  searchKbd2 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: searchKbd, children: searchKbd2 })
939
- ] }),
978
+ ] }) }),
940
979
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: actions, children: [
941
980
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: actionsInner, children: [
942
981
  onAccentChange && /* @__PURE__ */ jsxRuntime.jsx("div", { className: accentPicker, role: "group", "aria-label": "Brand colour", children: chunkLJ24EJ3N_cjs.accentColorNames.map((name) => /* @__PURE__ */ jsxRuntime.jsx(